PDA

Click to See Complete Forum and Search --> : openWindow


bmarzouk
Mar 8th, 2002, 05:36 AM
Hello,
I want to open another HTML file "FILE2.html" for example when a link in "File1.html" is clicked, and I want to control the appearance of the opened file "File2.html" to have no menubar, toolbar, and control its width or height, ... etc

I know that this is done by Javascript and here is the function to do it:

function OpenWindow(URL, Name)
{
open(URL,Name, "width=640,height=480,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollb ars=yes,status=0,toolbar=0")
}


but What I want is to transfer this code to the opened file, so I need not to run JavaScript in the source file "File1.html".

Can this be done?

mendhak
Mar 8th, 2002, 07:33 AM
not as far as I know.

Danial
Mar 8th, 2002, 08:23 AM
Originally posted by bmarzouk
Hello,
but What I want is to transfer this code to the opened file, so I need not to run JavaScript in the source file "File1.html".

Can this be done?

Not sure i understand what you mean by transfareing the code. If you mean you want to use the javascript on the first file on the second file aswell, then its should be pretty easy.

Put the all the javascript code in a js file and included that file in your first and 2nd file
e.g
<script language=javascript src=myscript.js></script>

No you can use the same script in both page.

Hope this helps
Danial

bmarzouk
Mar 8th, 2002, 08:36 AM
Dear all,

I am sorry if I didn't explain what I want to exactly,

How can I control the appearance of a browser window displaying HTML page by code written in the same HTML page?

I hope it's now more clear,
Thanks

Danial
Mar 8th, 2002, 09:33 AM
Hi,
I was just gonna reply saying no it cant be done, then just tried out something now and It works !! Only thing you need to add is close the inital window, i am working on it now.

Have a look at it.


<html>
<Head>
<Title>
Is It Possible?
</Title>
<script>
function winopen()
{
var url;
url=document.location.href;


pos=url.indexOf("AbC");

//i am adding this "AbC" to prevent an endless loop
//this will ensure that the page is only called once.
if (pos==-1)
window.open(url + "?AbC","test", "width=640,height=480,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollb ars=yes,status=0,toolbar=0") ;
}
</script>
</Head>
<Body onload="winopen()">

</Body>
</html>


You may have noticed i have added "AbC" string to identify if the page is called for the first time. This is not the best way as it might interfear if you using asp and querystring.

I was thinking if some how i could get the feature of the window, like if the window has toolbar, menu bar etc then it would be the best way.

Does anyone know if i can findo out if an window has a toolbar, menubar etc.

Thanks

scoutt
Mar 8th, 2002, 09:56 AM
the only way you can control the appearance of a browser window is if you opened that window up with javascript. you will not beable to change teh users default window.function OpenWindow(URL, Name)
{
open(URL,Name, " width=640,height=480,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=yes,status=0,toolbar=0")
}


but if you want to have a containerless window (chromeless) you can go here and read up on it.

http://www.snippetlibrary.com/tutorials.php?kid=74&catname=Windows

or some code
http://www.snippetlibrary.com/code.php?id=5&kid=20&catname=Popups