Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Change single number in embed attribute every time page visited

Question posted by: elbin (Newbie) on May 16th, 2008 11:59 AM
Hello,
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:

Code: ( text )
  1. <script type="text/javascript">
  2. function lista()
  3. {
  4. var list = "url=search_files/foret.swf&feuilles=2&objectif=100000000&texte=Keep   the left mouse button pressed <br> and move to look around.&zoomM=Zoom %2D&zoomP=Zoom %2B";
  5. document.embeds[0].setAttribute("flashvars", list);
  6. }
  7. </script>


and the whole <object> looks like this:

Code: ( text )
  1. <object id="Flash" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="377" width="481">
  2. <embed src="search_files/loader.swf" quality="high" bgcolor="#B3F285" name="<NAME>" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="377" width="481"></object>


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?
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
acoder's Avatar
acoder
Site Moderator
10,173 Posts
May 16th, 2008
06:15 PM
#2

Re: Change single number in embed attribute every time page visited
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.

Reply
elbin's Avatar
elbin
Newbie
27 Posts
May 19th, 2008
05:53 PM
#3

Re: Change single number in embed attribute every time page visited
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?

Reply
acoder's Avatar
acoder
Site Moderator
10,173 Posts
May 20th, 2008
09:02 AM
#4

Re: Change single number in embed attribute every time page visited
It probably doesn't work because the string being passed needs to be URL-encoded. Have you got it working with cookies?

Reply
elbin's Avatar
elbin
Newbie
27 Posts
May 20th, 2008
02:23 PM
#5

Re: Change single number in embed attribute every time page visited
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?

Reply
acoder's Avatar
acoder
Site Moderator
10,173 Posts
May 20th, 2008
02:42 PM
#6

Re: Change single number in embed attribute every time page visited
Read this technote by Adobe.

Reply
Reply
Not the answer you were looking for? Post your question . . .
174,850 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Javascript / DHTML / Ajax Forum Contributors