java script window.open() method

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

java script window.open() method

Post by Burrito »

I've used the window.open() method a ton in my web dev lifetime but I've always filled the first argument with a url to a separate page that I'm calling. I've seen it done in the past where people open a window and then write html to that window (I assume using document.write()).

I'm trying to do just that on this application I'm working on right now but so far not having much success accomplishing what I'm after which is to write a flash object to my child window.

I need to use a relative path to the flash object which is what is screwing it up as it can't find the object.

if I write my string to the flash object out in a div, it works fine.

likewise if I write out just some simple text to my child window, that works fine.

can anyone please inform me how this can be done using relative paths to images and objects?

thx,

Burr
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

yeah I have been able to get that far, my question is, how can I use a relative path for my html in the pop up window?

ex:

Code: Select all

function pickMp3(where)
{	
	var thplayer = document.getElementById('player');
	var str = '<a href="javascript:closeIt()"><img src="images/close.jpg" border="0" onMouseOver="this.src=\'images/close-over.jpg\'" onMouseOut="this.src=\'images/close.jpg\'"></a><br style="line-height:1px">';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="250" height="42" id="mp3test" align="middle">';
	str += '<param name="allowScriptAccess" value="sameDomain" />';
	str += '<param name="movie" value="flash/mp3.swf" />';
	str += '<param name="wmode" value="transparent" />';
	str += '<param name="FlashVars" value="ths='+where+'">';
	str += '<param name="quality" value="high" />';
	str += '<param name="bgcolor" value="#ffffff" />';
	str += '<embed src="flash/mp3.swf" FlashVars="ths='+where+'" quality="high" bgcolor="#ffffff" width="250" height="42" name="mp3test" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"/>';
	str += '</object>';
	if(document.searchForm.newwin.checked == true)
	{
		playWindow = window.open('','playerwindow','width=250,height=65');
		playWindow.document.write('<html><head><title>Media Player</title></head><body>');
		playWindow.document.write(str);
		playWindow.document.write('</body></html>');
		playWindow.document.close();
	}
	else
	{
		thplayer.innerHTML = str;
		thplayer.style.display = 'block';
	}
}
that does not show my flash object nor my image.

but if I change those relative paths to absolute paths (str += '<param name="movie" value="http://www.mydomain/flash/mp3.swf" />';)with my full domain, it works fine...that's what I'm trying to avoid
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

bah! I gave up and just created another page for it....
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

hm.... here are few articles describing same approach, however their doc.write function is saved in separate js file that is loaded in the header tag. It seems as if your function is within the document doc.write may not be aware of where to look for the files
http://hp.fuzzy76.net/archives/103-Find ... Flash.html
http://blog.deconcept.com/swfobject/
http://www.devpapers.com/article/109
http://thewarp.org/blog/index.cfm?mode= ... 5A8D713CDB
http://www.freddythunder.com/programs/codegen.php

Did you get the effect figured out? I've made few examples just to test the theory behind it.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

wtf wrote:Did you get the effect figured out? I've made few examples just to test the theory behind it.
by effect, I assume you are referring to our phone conversation about the 'white-out' effect?

if so, yes I did, it turns out you can do it all within flash by changing the brightness and contrast filters of a movie object to 100 percent, then motion tweening it back to 0 over a few frames (requires flash 8). I would like to figure out how to do it with action scripting down the road though because I'd like to make a dynamic slide show and have this effect be the transition between the slides.
Post Reply