Need script to 'OpenWindow' or 'Spawn'

T

tmb

- Want to open a 2nd browser window when someone clinks a link with the link
content inside it.
- Want to control window size
- Want all tool bars so only blue bar at top shows
- Can I put my content in the blue bar?
- Only options are Minimize, Maximize or Close (top right of blue bar)

1 - What is the difference in 'OpenWindow' and 'Spawn' ??

2 - Can anyone point me to a simple script I can use... or just post one...

I Googled this and everything I find has so many strings attached and wants
me to 'join' something that it discourages me from geetting proceeding with
them.

I just want a simple script and a little coaching on how to implement this.

Can anybody please help me?

Thanks - tmb
 
G

Grant Wagner

tmb said:
- Want to open a 2nd browser window when someone clinks a link with the link
content inside it.
- Want to control window size
- Want all tool bars so only blue bar at top shows
- Can I put my content in the blue bar?
- Only options are Minimize, Maximize or Close (top right of blue bar)

You can do all of the above (within limits of the user agent's abilities and
depending on whether some of the above features are excluded from what you can
achieve in a particular user agent) with the <attributes> parameter of the
window.open() method.

The only "content" you can put in the "blue bar" (more commonly called the
"titlebar", you _do_ know that it's not blue on many, many operating systems
don't you? and even on operating systems where it is blue, that can be changed
1 - What is the difference in 'OpenWindow' and 'Spawn' ??

Neither is a reserved word in Javascript, so they are probably just functions
written by Javascript authors. OpenWindow is presumably the name of some
function written by one Javascript author, Spawn is probably a function written
by another Javascript author. The difference between them would be the code
inside the functions.
2 - Can anyone point me to a simple script I can use... or just post one...

<script type="text/javascript">
function openWindow(lnk) {
if (window.open) {
return !window.open(lnk.href, lnk.target,
'width=400,height=300,resizable=1');
}

return true;
}
</script>
<!-- example usage -->
<a href="page.html" target="myNewWindow"
onclick="return openWindow(this);">Test</a>

The attributes string (3rd parameter of window.open()) is documented at:

<url:
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
/>

Internet Explorer supports a few more attributes (but don't use them unless
you're only supporting IE):

<url:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp />
I just want a simple script and a little coaching on how to implement this.

The problem with a simple script is that you are going to be unaware of the
issues involved in opening a new window. The conventional wisdom is that on the
general public Internet, opening a new window is very often the wrong choice. Go
to groups.google.com and search comp.lang.javascript for "open new window" to
see past discussions on this subject.

The way my solution is written, if Javascript is enabled, the "onclick" event
will fire and open the new window with the HREF and TARGET attributes specified
by the <A> tag. If the opening of the new window _appears_ to succeed (important
point, _appears_ to succeed, it may, in fact, not have been successful), then
the link is not followed and processing stops.

If Javascript is not enabled, or the user agent does not support window.open, or
window.open() appears to fail, then the link _is_ followed and the page will
open in a new window anyway (thanks to the TARGET attribute and subject to the
capabilities of the user agent), you just won't be able to control the size and
chrome of the new window.

But even this is not 100% guaranteed to open a new window containing your
content under every circumstance, in every user agent.

Please be aware that many, if not all, Web browsers now offer some degree of
popup blocking (they disable the ability to open new windows). If they do allow
new windows to be opened, many Web browsers can control the attributes which can
be applied to those new windows (for example, a new window may open, but it may
not be the size, or have the chrome that you requested).

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
T

tmb

Grant,

Just what I needed. Thanks.

tmb

Grant Wagner said:
You can do all of the above (within limits of the user agent's abilities and
depending on whether some of the above features are excluded from what you can
achieve in a particular user agent) with the <attributes> parameter of the
window.open() method.

The only "content" you can put in the "blue bar" (more commonly called the
"titlebar", you _do_ know that it's not blue on many, many operating systems
don't you? and even on operating systems where it is blue, that can be changed
by the user) is the contents of the <title></title> tags on the new HTML page
opened in that window.


Neither is a reserved word in Javascript, so they are probably just functions
written by Javascript authors. OpenWindow is presumably the name of some
function written by one Javascript author, Spawn is probably a function written
by another Javascript author. The difference between them would be the code
inside the functions.
one...

<script type="text/javascript">
function openWindow(lnk) {
if (window.open) {
return !window.open(lnk.href, lnk.target,
'width=400,height=300,resizable=1');
}

return true;
}
</script>
<!-- example usage -->
<a href="page.html" target="myNewWindow"
onclick="return openWindow(this);">Test</a>

The attributes string (3rd parameter of window.open()) is documented at:

<url:
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
/>

Internet Explorer supports a few more attributes (but don't use them unless
you're only supporting IE):

<url:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
/> this.

The problem with a simple script is that you are going to be unaware of the
issues involved in opening a new window. The conventional wisdom is that on the
general public Internet, opening a new window is very often the wrong choice. Go
to groups.google.com and search comp.lang.javascript for "open new window" to
see past discussions on this subject.

The way my solution is written, if Javascript is enabled, the "onclick" event
will fire and open the new window with the HREF and TARGET attributes specified
by the <A> tag. If the opening of the new window _appears_ to succeed (important
point, _appears_ to succeed, it may, in fact, not have been successful), then
the link is not followed and processing stops.

If Javascript is not enabled, or the user agent does not support window.open, or
window.open() appears to fail, then the link _is_ followed and the page will
open in a new window anyway (thanks to the TARGET attribute and subject to the
capabilities of the user agent), you just won't be able to control the size and
chrome of the new window.

But even this is not 100% guaranteed to open a new window containing your
content under every circumstance, in every user agent.

Please be aware that many, if not all, Web browsers now offer some degree of
popup blocking (they disable the ability to open new windows). If they do allow
new windows to be opened, many Web browsers can control the attributes which can
be applied to those new windows (for example, a new window may open, but it may
not be the size, or have the chrome that you requested).

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top