Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Alter xhtml in popup

    Hi,
    First off, thx j9ine for your help so far and for the following setAttribute code.

    http://www.buildrebuild.com/example.zip

    This works wonders but what I would ultimatley like to do is put an argumnet in the javascript link like this, so I can use it dynamically across all the links in one page.

    <a href="javascript:winInfo.winOpen('test2.htm', 'http://www.bytescout.com/demo/swfscout_SlideShowWithEffects.swf');">test</a>

    What this means is that I could change the swf from each link and not have to write out loads of javascript code and have it in separate popup pages...
    One popup page which accepts the argument form the xhtml and one xhtml page with alot of links with arguments for the popup.

    If anyone can help, pleeeaaase do.
    Thx in advance.
    CB

  • #2
    New Coder
    Join Date
    Nov 2006
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var winInfo = {
    
    	win: null,
    	flash: null,
    
    	winOpen: function(w,f) {
    		this.flash = f;
    		this.win = window.open(w,'newWin');
    		this.win.onload = this.changeParam;
    	},
    
    	changeParam: function() {
    		//remove existing object
    		var obj = winInfo.win.document.getElementsByTagName('object')[0];
    		winInfo.win.document.getElementsByTagName('body')[0].removeChild(obj);
    
    		var obj = winInfo.win.document.createElement('object');
    		obj.setAttribute('classid','clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
    		obj.setAttribute('width','200');
    		obj.setAttribute('height','150');
    		obj.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab');
    
    		var param1 = winInfo.win.document.createElement('param');
    		param1.setAttribute('name','movie');
    		param1.setAttribute('value',winInfo.flash);
    
    		var param2 = winInfo.win.document.createElement('param');
    		param2.setAttribute('name','wmode');
    		param2.setAttribute('value','transparent');
    
    		var embed = winInfo.win.document.createElement('embed');
    		embed.setAttribute('wmode','transparent');
    		embed.setAttribute('width','200');
    		embed.setAttribute('height','150');
    		embed.setAttribute('src',winInfo.flash);
    		embed.setAttribute('type','application/x-shockwave-flash');
    		embed.setAttribute('pluginspage','http://www.macromedia.com/go/getflashplayer');
    
    		obj.appendChild(param1);
    		obj.appendChild(param2);
    		obj.appendChild(embed);
    		winInfo.win.document.getElementsByTagName('body')[0].appendChild(obj);
    	}
    };
    
    <a href="javascript:winInfo.winOpen('test2.htm', 'http://www.bytescout.com/demo/swfscout_SlideShowWithEffects.swf');">test</a>

  • #3
    Regular Coder
    Join Date
    Feb 2006
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Awesome.
    Thx so much. This is too good.

    CB

  • #4
    Regular Coder
    Join Date
    Feb 2006
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://www.buildrebuild.com/linkArgument.htm

    Here is a working example. There are a couple of problems. If you click the first link, it changes the original attribute, but on subsequent clicks on that link or the second link, it reverts to the original attribute in the hmtl.

    I found that you have to close the popup window and then click on a link to make sure the attribute is set, but is there a way to use the same popup window, or close and reopen the same window?

    Thx
    Last edited by buildrebuild; 12-02-2006 at 10:54 PM.

  • #5
    New Coder
    Join Date
    Nov 2006
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code below will check to see if the popup window is open before changing the swf file. If the window is open then it will skip the win.onload command. That command is needed for the first time you open the window to insure that all of the elements are loaded before trying to remove or modify them. If the window is already open then you won't need that command. However, you will need to reset the win property in the winInfo object to null each time the popup is closed. That will force the script to use the onload event the next time the popup is opened. I have not tested this in IE but it is working without errors in FF.
    Code:
    //linkArgument.htm
    <html><head>
    
    <script>
    var winInfo = {
    
    	win: null,
    	flash: null,
    
    	winOpen: function(w,f) {
    		this.flash = f;
    		if (!this.win) {
    			this.win = window.open(w,'newWin','width=500,height=500,toolbar=no,location=no,status=no,scrollbars=no,resizeable=no');
    			this.win.onload = this.changeParam;
    		} else {
    			this.changeParam();
    		}
    	},
    
    	changeParam: function() {
    		var obj = winInfo.win.document.getElementsByTagName('object')[0];
    		winInfo.win.document.getElementsByTagName('body')[0].removeChild(obj);
    
    		var obj = winInfo.win.document.createElement('object');
    		obj.setAttribute('classid','clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
    		obj.setAttribute('width','200');
    		obj.setAttribute('height','150');
    		obj.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab');
    
    		var param1 = winInfo.win.document.createElement('param');
    		param1.setAttribute('name','movie');
    		param1.setAttribute('value',winInfo.flash);
    
    		var param2 = winInfo.win.document.createElement('param');
    		param2.setAttribute('name','wmode');
    		param2.setAttribute('value','transparent');
    
    		var embed = winInfo.win.document.createElement('embed');
    		embed.setAttribute('wmode','transparent');
    		embed.setAttribute('width','200');
    		embed.setAttribute('height','150');
    		embed.setAttribute('src',winInfo.flash);
    		embed.setAttribute('type','application/x-shockwave-flash');
    		embed.setAttribute('pluginspage','http://www.macromedia.com/go/getflashplayer');
    
    		obj.appendChild(param1);
    		obj.appendChild(param2);
    		obj.appendChild(embed);
    		winInfo.win.document.getElementsByTagName('body')[0].appendChild(obj);
    	}
    };
    /*You can change the attributes eg The location of the swf and the mp3 to be played as below. It will be inserted with rest of object
    as 'winInfo.flash'.*/
    </script><!-- base href="http://www.buildrebuild.com/linkArgument.htm" --></head><body>
    
    <a href="javascript:winInfo.winOpen('test2.htm', 'http://www.buildrebuild.com/singlemp3player.swf?file=http://www.buildrebuild.com/audio/dirtyDeeds2.mp3');">test</a><br>
    <a href="javascript:winInfo.winOpen('test2.htm', 'http://www.buildrebuild.com/singlemp3player.swf?file=http://www.buildrebuild.com/mp3/Cherrybomb.mp3');">test</a>
    </body></html>
    Code:
    //test2.htm
    <html>
    <head>
    <script>
    window.onunload = resetWin;
    
    function resetWin() {
    	window.opener.winInfo.win = null;
    }
    </script>
    </head>
    <body>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="150" height="20">
      <param name="movie" value="http://www.buildrebuild.com/singlemp3player.swf">
      <param name="quality" value="high">
      <embed src="http://www.buildrebuild.com/singlemp3player.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="150" height="20"></embed>
    </object>
    </body>
    </html>

  • #6
    Regular Coder
    Join Date
    Feb 2006
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah. Works great in ff but in good ol' IE 5.1+ it doesn't.
    Will continue to research why it doesn't work in IE.

    I am now trying to write out the swf with the flash embed object for IE.

    <script type="text/javascript">
    var fo = new FlashObject("singlemp3player.swf?file=http://www.buildrebuild.com/audio/dirtyDeeds2.mp3", "animationName", "770", "230", "6", "#fff");
    fo.addParam("allowScriptAccess", "sameDomain");
    fo.addParam("quality", "high");
    fo.addParam("scale", "noscale");
    fo.addParam("loop", "false");
    fo.write("flashcontent");
    </script>

    Not sure how to alter the other script as most of the info isn't contained within attributes.

    Best
    CB
    Last edited by buildrebuild; 12-03-2006 at 12:26 PM.

  • #7
    Regular Coder
    Join Date
    Feb 2006
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also, for the first example, I'm having problems cutting out the popup and just using the code for an iframe in the same page as the link.

    Best


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •