By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,903 Members | 638 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,903 IT Pros & Developers. It's quick & easy.

Change single number in embed attribute every time page visited

P: 27
first to say that I am a total beginner in Javascript but I know some programming (python in particular) and am able to understand methods/parameters and so on.

Here's my problem:
I am trying to set up a page that changes every time it's visited, but without using php(which i don't know either) because it's not active on the server. The thing that should change is a single number in one attribute of an <embed> tag inside an <object>. The attribute itself is a long string of attributes - settings for the flash that runs in this embed-tag. In general I would like to change the number according to a file storing the number of visits and increments it with each new visit. So I need to set the whole attribute (which is a string called 'list' in the code below) from outside - with a javascript.

What I am trying now is simply setting the attribute without any changing/files. It looks like this:

[HTML]<script type="text/javascript">
function lista()
var list = "url=search_files/foret.swf&amp;feuilles=2&amp;objectif=100000000&am p;texte=Keep the left mouse button pressed &lt;br&gt; and move to look around.&amp;zoomM=Zoom %2D&amp;zoomP=Zoom %2B";
document.embeds[0].setAttribute("flashvars", list);

and the whole <object> looks like this:

[HTML]<object id="Flash" codebase=",0,40,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="377" width="481">
<embed src="search_files/loader.swf" quality="high" bgcolor="#B3F285" name="&lt;NAME&gt;" type="application/x-shockwave-flash" pluginspage="" height="377" width="481"></object>[/HTML]

I execute the function onload but the flash doesn't seem to get the parameters and stops after it's initial animation contained in the loader.

Where am I making a mistake?
May 16 '08 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 15k+
P: 16,027
To change the number each time without using server-side code, you need to use cookies.

Changed the thread title to better describe the problem.
May 16 '08 #2

P: 27
Thank you for changing the title, I'll write more specific next time. Now i understand the cookies, but I still don't know why the code I gave you doesn't work. It doesn't set the embed attribute. I suppose I should put it into the checkCookie function that executes onload, but why doesn't it work?
May 19 '08 #3

Expert Mod 15k+
P: 16,027
It probably doesn't work because the string being passed needs to be URL-encoded. Have you got it working with cookies?
May 20 '08 #4

P: 27
I tried it but it doesn't work. I put the setattribute statement in the case when the cookie does not exist.

When I said I understood cookies I didn't mean I was able to use them, I just understand what they do generally. What do you mean URL-encoded?
May 20 '08 #5

Expert Mod 15k+
P: 16,027
Read this technote by Adobe.
May 20 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.