PDA

View Full Version : generating new window from form and keeping variables


g00fy
03-11-2003, 12:06 PM
i have a page with alot of thumbnails in a form and i pass the image name via GET to another page which runs a movie with the same
name but an extension appended.
the problem is that the script i have written gets the name from the URL of the form
http://page.html?name.x=123&name.y=456

*the whole problem is that i want a 'toolbarless' window, it works fine if i leave the toolbars but the page looks
crap with a heap of toolbars and only a quicktime player in it.

however if i use a script to generate a popup the URL is of the form
http://javascript:function(URL) and i cant get the image(& movie) name from it :(

is there a way to do this *cleanly*, what i am doing atm is genrating a normal window via
target="_blank" and then running a function onLoad to recreate that window with no toolbars at all.

its a bit clumsy, and i'm looking for suggestions to fix it, as the whole site is to showcase my clients movies.

i can generate the URL(using js) that the form would generate but it would be even more clumsy to add thumbnails and movies to

below is the code i have written so far:

all this code is on the same page.

<script language="JavaScript">
function load(){
// these bits get around prompt on parent window close :)
parentWin = window.opener;
parentWin.opener = window.self;
//
if(this.window.name != 'win2')
setTimeout("reload()", 0);
parentWin.close();
this.window,resizeTo(400,300);
this.window.moveTo(100,100);
}
</script>
<body onLoad="javascript:load()">
<!-- script & form to pass file name to quicktime //-->
<FORM NAME="movie">
<INPUT TYPE="hidden" NAME="preview">
</FORM>
<SCRIPT LANGUAGE="javascript">
<!--
var locate = window.location.href
document.movie.preview.value = locate
var text = document.movie.preview.value

function getNameFromUrl(str){
theleft = str.indexOf("?") + 1;
theright = str.lastIndexOf("x=");
return(str.substring(theleft, theright));
}
var mpgFile = ( getNameFromUrl(text) + 'mpg' );
//-->
</SCRIPT>
<script>
document.write(' <object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="320" height="256" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">');
document.write(' <param name="src" value='+ mpgFile +' ');
document.write(' <param name="autoplay" value="false"> ');
document.write(' <param name="loop" value="false"> ');
document.write(' <param name="controller" value="true"> ');
document.write(' <embed src='+ mpgFile +' width="320" height="256" autoplay="false" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed> ');
document.write(' </object> ');
</script>

</body>



any help would be greatly appreciated :thumbsup:

kind regards,

g00fy

beetle
03-11-2003, 02:45 PM
<script>
function doSubmit()
{
var popWin = window.open( ... );
return true;
}
</script>

<form target="popWin" onsubmit="return doSubmit()" ... >

g00fy
03-12-2003, 02:10 AM
thanx for the reply beetle :)

i tried your code but i didnt get the url being passed properly, so i resorted to cookies:

here's what i cam up with, eventually i will extend to allow for specifying directory and file extension in the setCookie() call

thanx again :thumbsup:

<script>
function doSubmit(){
var cook = document.cookie;
var url = "movie_page.htm" + "?" + cook + ".x=";
var popWin = window.open(url,'',"width=410,height=310,");
return false;
}
function setCookie(movieName){
document.cookie = movieName;
}
</script>

// called with

<form name="show" method="GET" target="popWin" action="movie_page.htm" onSubmit="return doSubmit()">
<input type="image" src="apollo.jpg" width="113" height="91" border="0" onClick="javascript:setCookie('apollo')">


and the movie_page.htm

<!-- script to pass file name to quicktime //-->
<FORM NAME="movie">
<INPUT TYPE="hidden" NAME="preview">
</FORM>
<SCRIPT LANGUAGE="javascript">
<!--
var locate = window.location.href
document.movie.preview.value = locate
var text = document.movie.preview.value

function getUrl(str){
theleft = str.indexOf("?") + 1;
theright = str.lastIndexOf("x=");
return(str.substring(theleft, theright));
}
var mpgFile = ( getUrl(text) + 'mpg' );
//-->
</SCRIPT>
<script>
document.write(' <object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="300" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">');
document.write(' <param name="src" value='+ mpgFile +' ');
document.write(' <param name="autoplay" value="true"> ');
document.write(' <param name="loop" value="false"> ');
document.write(' <param name="controller" value="true"> ');
document.write(' <embed src='+ mpgFile +' width="400" height="300" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/">Please wait while movie loads</embed> ');
document.write(' </object> ');
</script>


now that i have looked at the code on this page i can just pass the movie name as the cookie and reduce the code in the movie_page :)