Click to See Complete Forum and Search --> : window.open! please help!
shard
03-22-2003, 08:09 PM
hi... i am using this code of Mr. Khalid... but, being a newbie, am unable to use it to replace the popup with my desired file... please help!
function openWin(url) {
var popupWin=window.open("main2.htm","popupWin","scrollbars=no,locationbars=no");
winW = (document.all)?screen.width:window.screen.availWidth;
winH = (document.all)?screen.height:window.screen.availHeight;
myTitle = "Khalid Ali's Popup window."
popupWin.document.write('<title>'+myTitle+'</title>');
popupWin.document.open();
popupWin.document.write("<br>Auto Generated Window<br><a href=\"javascript:self.close()\">Close me</a>");
popupWin.document.close();
popupWin.resizeTo(winW,winH);
popupWin.moveTo(0,0);
closeMe();
}
function closeMe() {
window.opener = top;
window.close();
}
shard
03-22-2003, 08:30 PM
well thats the problem... even if i write the code like this:
function openWin(url) {
var popupWin=window.open("main2.htm","popupWin","scrollbars=no,locationbars=no");
winW = (document.all)?screen.width:window.screen.availWidth;
winH = (document.all)?screen.height:window.screen.availHeight;
popupWin.document.open();
popupWin.document.close();
popupWin.resizeTo(winW,winH);
popupWin.moveTo(0,0);
closeMe();
}
function closeMe() {
window.opener = top;
window.close();
}
it doesn't replace itself with main2.htm... instead it just generates a new popup window that replaces itself and maximizes accordin to the user's resolution! well thats brilliant and i exactly want to use the very feature but with slight difference that the maximized window should be main2.htm and not the automatically generated one! i hope u can help!
shard
03-22-2003, 08:44 PM
thanks a lot sir for ur time and sorry to bother you with very basic questions but
1. where should i specify the name of the url i wanna display
2. now the window open a new popup but doesn't close its own self... how to overcome that?
u can visit www.themightythor.com to see how that sites executes a same themetic sequence... i want something like this!
i just visited ur website... great site and great skills! i thankya a lot for ur precious time...!
shard
03-22-2003, 08:54 PM
Ans 1: onload i,e:
<body onLoad="openWin();" class="body">
Ans 2: almost oimmediately!
i am basically a designer and work in flash and maya just for fun... so i don't know much about the language stuff but now i am trying to improve my self in this field to work in ActionScriptin of Flash and MEL of Maya..... so please don't let any of my questions or answers bother ya!
shard
03-22-2003, 09:07 PM
sorry! ans#2 was wrong! lol! i infact don't want to close the popup!
thankya sir for your help! i tried the code and its workin' perfectly! guess i have to learn a lot to understand the different behavorial attributes of JS in head and body blocks! thanks once again and i hope that in case of any further probs i can seek your further help!:)
shard
03-22-2003, 09:34 PM
please see the code below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Yeah!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="JavaScript">
function openWin(url) {
if (screen.width >= 1024 && screen.height >= 768)
{
var popupWin=window.open(url,"popupWin","scrollbars=no,locationbars=no");
winW = (document.all)?screen.width:window.screen.availWidth;
winH = (document.all)?screen.height:window.screen.availHeight;
myTitle = "Why Not!"
popupWin.document.write('<title>'+myTitle+'</title>');
popupWin.document.open();
popupWin.document.close();
popupWin.resizeTo(winW,winH);
popupWin.moveTo(0,0);
closeMe();
}
else {
alert("Not enuf resolution! 1024x768 minimum required!")
}
}
function closeMe() {
window.opener = top;
window.close();
}
</script>
</head>
<body onLoad="openWin('main2.htm');" class="body">
</body>
</html>
when i load this page what happens is that the page itself maximizes to my screen resolution (i have my 17" monitor's resolution set to 1280x1024) and NOT 'main2.htm'... there r no traces of any pop ups and thats kool... but the problem is that there aint no traces of main2.htm either! what went wrong mr.Dave sir?
shard
03-22-2003, 10:50 PM
Ah yessss!!! my mistake..! i somehow pasted these lines while editing my page! thanks so a lot mr Dave... u have been of the greatest help!!! now the page is working pretty fine!
2 questionz from learning point of view tho...
1. popupWin.document.open() is a dot synatx and as far as i know dot syntax is used to call a fucntion, i.e, fucntion.property... then how in the name of God we can use the names of variables before that function and then how does it work? does it then work only for the very variable? did i miss something while readin' about the dot synatax?
2. what is the best way, according to your experience to learn a language fastly if u r basically a designer?? i mean ya know the tastes differ!!
thanx once again!
shard
03-23-2003, 03:03 PM
thankya mr. dave once again u have been very helpful! i really adore your knowledge bout javascript... i wish i was so good at it too... ah well!!! i'll try!!! thumb's up for ya!!!... and... well... me!!!!:D