471,863 Members | 933 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,863 software developers and data experts.

Change single number in embed attribute every time page visited

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="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">
<embed src="search_files/loader.swf" quality="high" bgcolor="#B3F285" name="&lt;NAME&gt;" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" 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
5 2044
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
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
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
16,027 Expert Mod 8TB
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.

Similar topics

11 posts views Thread by Anna | last post: by
9 posts views Thread by Muffinman | last post: by
19 posts views Thread by felixnielsen | last post: by
1 post views Thread by richardscheff | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.