...

View Full Version : odd result when using two javascript:newWin('url') scripts together



canadianjameson
05-31-2004, 08:10 PM
when i try to use the same script twice on a page (renamed appropriately i assume), i get the oddest thing happening. the width & height variables in the first instance of the script (directly below) dont get read... or they get overwritten. in any case... the window opens full screen.

the only way i can get around this is to open a link in the second script using <a href="javascript:newWinPDF('url'), keep that open, and THEN for some reason the other script works properly...

any ideas why this may be

i think you may be able to see it at www.enviromark.ca/sitetest/english/products.html --> Greyline --> Stingray



<script type=text/javascript>
function newWin(urlLoc) {
_winName = "popupSelect";
_info = "toolbar=no"; // yes|no
_info += ",location=no"; // yes|no
_info += ",directories=no";// yes|no
_info += ",status=no"; // yes|no
_info += ",menubar=no"; // yes|no
_info += ",scrollbars=no";// yes|no
_info += ",resizable=yes"; // yes|no
_info += ",dependent"; // close the parent, close the popup, omit if you want otherwise
_info += ",height=250";
_info += ",width=425";
_info += ",left=465";
_info += ",top=100";
DispWin=window.open(urlLoc,_winName,_info);
}
</script>

<script type=text/javascript>
function newWinPDF(urlLoc) {
_winName = "MyNewWindow1";
_info = "toolbar=yes"; // yes|no
_info += ",location=no"; // yes|no
_info += ",directories=no";// yes|no
_info += ",status=no"; // yes|no
_info += ",menubar=no"; // yes|no
_info += ",scrollbars=yes";// yes|no
_info += ",resizable=yes"; // yes|no
_info += ",dependent"; // close the parent, close the popup, omit if you want otherwise
DispWin=window.open(urlLoc,_winName,_info);
}
</script>

Willy Duitt
05-31-2004, 09:43 PM
That script is written to be reused by numerous links. Why do you feel the need for two instances of the same script? That defeats its purpose. However, if you want to continue this folly. Change the window name and variable names.

canadianjameson
06-01-2004, 01:52 AM
i use two instances of the function because they require different setting, as seen in the yes/no differences in the two scripts.

as for using different function name & window names, i have already done that. unless i'm crazy

What else is going wrong.

Willy Duitt
06-01-2004, 02:00 AM
Change your global variable names or make them local to the function. But if it was me, I would use the same function and pass the various window attributes as arguements.

canadianjameson
06-01-2004, 05:45 AM
... But if it was me, I would use the same function and pass the various window attributes as arguements.

can you give me a code example of how i would do this?

MikeFoster
06-01-2004, 02:24 PM
Like this...


// from the X Library v3.15.2, Licensed LGPL (cross-browser.com)

function xWindow(name, w, h, x, y, loc, men, res, scr, sta, too)
{
var f = '';
if (w && h) {
if (document.layers) f = 'screenX=' + x + ',screenY=' + y;
else f = 'left=' + x + ',top=' + y;
f += ',width=' + w + ',height=' + h + ',';
}
f += ('location='+loc+',menubar='+men+',resizable='+res
+',scrollbars='+scr+',status='+sta+',toolbar='+too);
this.features = f;
this.name = name;
this.load = function(sUrl) {
if (this.wnd && !this.wnd.closed) this.wnd.location.href = sUrl;
else this.wnd = window.open(sUrl, this.name, this.features);
this.wnd.focus();
return false;
}
}

canadianjameson
06-01-2004, 03:44 PM
how would i impliment this?

is it in conjunction with the above scripts, or is it another window script?

MikeFoster
06-01-2004, 03:47 PM
It is yet another new window script ;-)

Have a look here (http://cross-browser.com/x/examples/xwindow.html).

canadianjameson
06-01-2004, 03:48 PM
haha, the issue being that I, as a supreme n00bie, enjoyed the idiotproofness of my other scripts :)

do you know how i'd modify those to fix my problem, willy told me how above, but i couldnt make it work



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum