PDA

View Full Version : window size


sarah
08-06-2003, 12:58 PM
Hi

I have a link that currently opens test.html I want to open the webpage in a new window but the window then has to be a fixed size.

I got my head round the new window by using target="_blank" but I can't seem to get the window size sorted.

Also I dont wat the user to be able to resize it or use scrollbars - is this possible?

Thanx

Sarah

marek_mar
08-06-2003, 01:13 PM
A sample link:
<a href="javascript:window.open('test.htm','test','width=620,height=580,toolbar=no,scrollbars=no,status=yes,r esizable=no,menubar=no');">To test</a>
It shuld be in one line but it just splits it in two.

sarah
08-06-2003, 02:29 PM
Hi,

I tried the following:

<a href='javascript:window.open('dinner.html','dinner','width=450, height=620,toolbar=no,scrollbars=no,status=yes,resizable=no,menubar=no')';>

and I get an error when it opens up a new page. It doesnt display the webpage in the new window. The address bar says:

javascript:window.open(

with an error message:

javascript:window.open(||outbind://64-000000000...

Lazaroth
08-06-2003, 08:05 PM
It's used like this:

<a href="#" onclick="javascript:window.open('dinner.html','dinner','width=450, height=620,toolbar=no,scrollbars=no,status=yes,resizable=no,menubar=no');">click here</a>

cheesebag
08-06-2003, 08:14 PM
<a href="dinner.html" target="dinner" onclick="window.open(this.href,'dinner','width=450,height=620,status');return false;">


Try using double quotes for your HTML; you can't nest singles inside singles.

Lazaroth...it's not used like this:

onclick="javascript:windo.....

Lazaroth
08-06-2003, 08:29 PM
Usually I never use

onclick="javascript:window.op.....",

I write the code as it is

onclick="window.op....."

It doesn't matter (in this case) if I write javascript before, some older browsers require a "javascript:" before a script even.

To use href as you do or as I do doesn't matter since the result is the same (I even think my is slightly faster since you use this.href).

cheesebag
08-06-2003, 08:42 PM
some older browsers require a "javascript:" before a script even.They do? That's a (pseudo-)url; it's not designed to be used inside event handlers. The fact that they tolerate it is irrelevant, although it might allow for inline language changes...pretty rare.

Does the method you posted open a new window in javascript-disabled browsers? That's the whole point...:rolleyes:

Lazaroth
08-06-2003, 08:55 PM
Perhaps not, but then again, how many uses a browser that is javascript-disabled. ;)

The method I posted is instead compitable with functions with the positive side-effects (your's too if you replace this.href with 'dinner.html' :rolleyes: ).

I.e.

<script>

function openit()
{

var site = "dinner.html";

window.open(site,'dinner','width=450, height=620,toolbar=no,scrollbars=no,status=yes,resizable=no,menubar=no');
}

</script>


<body>


<a href="#" onclick="openit(); return false;">click me</a>

glenngv
08-07-2003, 12:15 PM
it's all about good programming practice.
try to code with backward compatibility as possible.

function openit(url,target)
{
var w = window.open(url,target,'width=450,height=620,toolbar=no,scrollbars=no,status=yes,resizable=no,menuba r=no');
w.focus();
return false;
}
...
<a href="bfast.html" target="bfast" onclick="return openit(this.href,this.target)">
<a href="lunch.html" target="lunch" onclick="return openit(this.href,this.target)">
<a href="dinner.html" target="dinner" onclick="return openit(this.href,this.target)">
...
<a href="noJavascriptPage.html" onclick="dontGoSomewhereElseJustDoSomething();return false">Do something</a>