It looks like you're new here. If you want to get involved, click one of these buttons!
[img[image-1][1]]I want these images to be placed randomly in the page.
var largeurEcran = (document.body.clientWidth); var hauteurEcran = (document.body.clientHeight); var symbole = document.getElementsByClassName("internalLink"); for (var i=0; i<symbole.length; i++) { symbole[i].style.left = Math.floor((Math.random() * (largeurEcran - largeurEcran/1.5)) + largeurEcran/3) + "px"; symbole[i].style.top = Math.floor((Math.random() * (hauteurEcran - hauteurEcran/2)) + hauteurEcran/4) + "px"; }
Comments
You also need to state which story format you're using, too. Sugarcane is the default.
In Sugarcane, this should work:
For the story format, I actually don't know which one I am using, but if you say Sugarcane is the default I suppose it is this one.
I think my post is not very clear, but what I want is not to display images randomly but to attribute to each image a random position (top - left) in the page with css and javascript.
If you read the Twine Wiki page on Scripts there is a section about prerender and postrender which can be used to execute Javascript either before or after the passage has been rendered. If you want the script to only be executed for a single passage then you can use the passage() function to check, if you want it to be executed for a limited set of passages then you can assign a tag to those passages and use the tags() to check for that tag.
But I don't understand how to use this "postrender" function. I did that but it doesn't work :
But I just have one question, why is it : and no ?
TL;DR: Personal preference when using the task objects.