473,378 Members | 1,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Need script to 'OpenWindow' or 'Spawn'

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
Jul 23 '05 #1
2 2294
tmb wrote:
- 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
by the user) is the contents of the <title></title> tags on the new HTML page
opened in that window.
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/...ce/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/a...ods/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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 23 '05 #2
tmb
Grant,

Just what I needed. Thanks.

tmb

"Grant Wagner" <gw*****@agricoreunited.com> wrote in message
news:40***************@agricoreunited.com...
tmb wrote:
- 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 by the user) is the contents of the <title></title> tags on the new HTML page opened in that window.
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/...ce/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/a...ods/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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kevin Cheramie | last post by:
I'm unsure how to break down and use what is returned by expect in the rest of my script. I want to issue a command and split the results of that command into several different variables. I then...
1
by: Krechting | last post by:
Hi All, I need a button on my form that opens a new window. I put in a submit button but it always returns to my first page. And then my first page is empty. What button do I need to go to...
3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
0
by: Krutibas Biswal | last post by:
Hi, I am using a script 'unbuffer' for unbuffering my outputs when using pipes. This script is based on expect and looks like this : ----------------------------------------------...
4
by: Jani Yusef | last post by:
I want to create a tree of processes. The depth of the tree is given by the variable depth and the number of processes started by each node is given by the variable numberOfProcesses. Is the...
2
by: vmalhotra | last post by:
Hi I am new in python scripting. I want to open a Multiple telnet session through once script. In other way i can tell i want to open two linux consoles through one script. I wrote one...
3
by: sophie_newbie | last post by:
Hi, I have a cgi script that performs a very long computation that can take several hours to complete. Is there any smart way that I can keep this script running until it is finished (after the...
1
by: sophie_newbie | last post by:
I've posted something similar to this already, but now I'm more sure of what I'm asking. Basically I've a CGI script, that when executed by the user, I want to call another script that does a...
3
by: bollweevil | last post by:
Hello Everyone, I do Django web development on my Mac at home, and then I rsync the files with the Ubuntu web server. I want to write one single bash shell script that rsyncs the files and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.