-
Is there a way to set a click through url on a swf using javascript? The situation is I have swf's that are given to me and they can not be edited however I need to attach a url to it for a click through. I get flash ads with no "get url" function set to them and I am supposed to some how attach a URL to the swf? I was thinking of building a film loader swf that sets the url with a particular movie, kind of like a swf jukebox, but that seemed over kill if I could do it all with javascript. Any ideas? Thanks.
Details:
This has to work in both IE and NS and I am working in a asp environment.
-
Hi,
I have managed to add variables to existing movies via php and perl server scripts, and I think I could add links as well...
Rather than editing the swf, such code would build the geturl part (a button as big as the flash ad) and integrate it with the existing movie. So you would run the program or script on a movie you receive, and then use the output of the program on your website. The visitor would only see the amended movie, so no javascript or other source of potential failure
Musicman
-
Assuming you are printing out the swf banner ads with javascript, you can enclose the banner and a single period or other virtually invisible character within an html link with the appropriate URL (spaces don't work for all browsers all the time in my exprience). This will make the entire banner clickable as a normal html link. It will not work (at least on IE) without a character enclosed within the same link tag as the swf banner.
This is how I've made the output of my MingWorks basic swf banner maker clickable (and right clickable for save-as downloading).
Jerry
-
Do you have sample code I could look at? Or point me to a resource that might have code samples?
Thanks again
-
Of course it depends upon how you select the appropriate swf banner and url combination.
Code:
<script language="JavaScript">
<!--
function makeAd(){
// This would be your ad selection code
// This is not necessary if using a
// server side script for ad selection
// Here we are returning the link and swf url
// which your code would provide
stuff=new Array();
stuff[0]=linkurl;
stuff[1]=swfsrc;
return stuff;
}
// call the function to grab the variables
bannerCodes=makeAd();
// create the banner/link tag (with added character)
// using the linkurl and swfsrc from our function
adCode='<a href="'+bannerCodes[0]+'">.<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0"
ID=objects WIDTH=468 HEIGHT=60>
<PARAM NAME=movie VALUE="'+bannerCodes[1]+'">
<EMBED src="'+bannerCodes[1]+'" WIDTH=468 HEIGHT=60 TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</OBJECT></a>';
// write out the banner/link code
document.write(adCode);
--!>
</script>
Note-this is just a sample off the top of my head.
Jerry
-
I tried to wrap the object tag in a href as posted, but it does not create a link on the swf just on 1x1 pixel link. Can you place a href around a object tag?
posted code:
// create the banner/link tag (with added character)
// using the linkurl and swfsrc from our function
adCode='<a href="'+bannerCodes[0]+'">.<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0"
ID=objects WIDTH=468 HEIGHT=60>
<PARAM NAME=movie VALUE="'+bannerCodes[1]+'">
<EMBED src="'+bannerCodes[1]+'" WIDTH=468 HEIGHT=60 TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</OBJECT></a>';
-
Yes you can, with the addition of text inside the link tag.
Could you post an example URL where the swf doesn't load as you said? Perhaps your(my) script isn't placing the URL of the swf file into the array? Perhaps my function call isn't correct (been awhile since I did much JS).
Perhaps you could try it without a function call?
[code]<script language="JavaScript">
<!--
// set href and object/embed urls
linkHREF=THIS_LINKS_URL;
swfSRC=THIS_SWF_URL;
// create the banner/link tag (with added character)
// using the linkurl and swfsrc from our function
adCode='<a href="'+linkHREF+'">.<OBJECT classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0"
ID=objects WIDTH=468 HEIGHT=60>
<PARAM NAME=movie VALUE="'+swfSRC+'">
<EMBED src="'+swfSRC+'" WIDTH=468 HEIGHT=60 TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</OBJECT></a>';
// write out the banner/link code
document.write(adCode);
--!>
</script>
[\code]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|