Hi,
I have this code in the head of the page:
script language="JavaScript" type="text/JavaScript">
<!--
function goTo(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
and this bit in the body section:
<form name="form1" method="post" action="">
<select name="select" onChange="goTo('self',this,0)">
Simple put I want the new page to open in a new window, I assumed that
changing the 'self' bit to 'blank' would work but all I get are JavaScript
undefined error messages.
Does anybody have any other ideas as to what I could try ?
Thanks 2 2217
"Andy" <an******@hotmail.com> writes: script language="JavaScript" type="text/JavaScript">
The language attribute is deprecated and can safely be omitted
<!--
This HTML comment starter can also safely be omitted. function goTo(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
Yikes. Bad use of eval. You will probably never need to use eval, as
there are better alternatives.
Just use:
function goTo(tObj,selObj,restore) {
tObj.location=selObj.options[selObj.selectedIndex].value;
...
and
<form name="form1" method="post" action=""> <select name="select" onChange="goTo('self',this,0)">
onchange="goTo(self,this,false);"
Simple put I want the new page to open in a new window, I assumed that changing the 'self' bit to 'blank' would work but all I get are JavaScript undefined error messages.
This code is only built to open in existing windows.
Does anybody have any other ideas as to what I could try ?
function goToNew(winName,selObj,restore) {
var win = window.open(selObj.options[selObj.selectedIndex],winName);
if (restore) {selObj.selectedIndex=0;}
return win;
}
called as, e.g.:
onchange="goToNew('_blank',this,false);"
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
On Sat, 17 Apr 2004 20:42:42 +0100, Andy <an******@hotmail.com> wrote: I have this code in the head of the page:
script language="JavaScript" type="text/JavaScript">
The language attribute is deprecated, and the presence of the type
attribute makes it redundant. Remove it.
<!--
Script hiding is a practice that is now obsolete. Remove the SGML comment
delimiters.
function goTo(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
Why are you using eval()? I don't see why you can't just make targ an
object reference and then write:
targ.location.href = selObj.options[ selObj.selectedIndex ].value;
Notice that there is no need to convert the value property to a string.
The form control values are *always* returned as strings.
if (restore) selObj.selectedIndex=0; } //-->
Remove this delimiter along with the first.
</script>
and this bit in the body section:
<form name="form1" method="post" action=""> <select name="select" onChange="goTo('self',this,0)">
To work with the changes above, change the call to
goTo(self,this,false)
I changed the last argument to false because it makes more sense to pass
booleans when evaluating booleans.
Simple put I want the new page to open in a new window, I assumed that changing the 'self' bit to 'blank' would work but all I get are JavaScript undefined error messages.
That's because "self" is an object reference to the current window
(equivalent to window.self or window), whereas "blank" isn't defined at
all.
Does anybody have any other ideas as to what I could try ?
A call to window.open(), perhaps?
Two things to note:
1) Don't perform navigation actions on the "change" event.
2) Avoid new windows completely, if possible.
If I use my mouse wheel to change the value, the event will fire every
time even though I probably haven't chosen a destination yet. Similarly,
if I make a mistake when choosing a value, I will not get an opportunity
(unless I'm very quick) to correct it. Use a button instead.
Mike
--
Michael Winter M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul |
last post by:
I link to a web site from an Excel spreadsheet. The page i link to is
getCookie.asp which sets a cookie then returns back some html which opens a
new window, to the same site but a different page...
|
by: Les |
last post by:
Hi,
I'd like to find out how to use the window.open() script in Fireworks MX. I have posted my question in the Fireworks forum but
didn't get any replies. Since it's javascript, maybe someone...
|
by: Marshall Dudley |
last post by:
When I do the following line in Netscape, the popup loads as it should,
but the parent window usually, but not always, reloads as well.
<a href="#"...
|
by: David McCulloch |
last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it.
Why not?
(Don't ask why I simply did not open the window with the new size....my
original problem was how to open a...
|
by: Samir Pandey |
last post by:
Hello,
I am using the following javascript code to open a new window.
Somehow, IE always opens a new window. It doesn't open target url in
the window name given.
All i want is, if there is a...
|
by: NeverLift |
last post by:
But, if it's not open, I don't want to open it . . . using
window.open will open it if it doesn't exist, even if the url in that
open is null (the window is then empty -- but it's open).
The...
|
by: Larry R Harrison Jr |
last post by:
I have pull-down menus in javascript and I have the code for opening a link
in a new window. But I want it to open a full-sized window. I can't figure
out the syntax. What I have so far:
...
|
by: Dominic Tocci |
last post by:
I'm searching for a way to use window.open on my web page to open a window
in firefox that allows the sidebars to work (bookmarks, history, etc).
When I use the following:
var...
|
by: anthony.turcotte |
last post by:
Hi,
I've looked for a solution to this problem on google, read posts in
this newsgroup and I still haven't found anything that could help me.
Here's the scenario.
1. User accesses...
|
by: Geoff Fox |
last post by:
I am in the final moments of designing a new website. One of the pages
(http://www.auditionfactory.com/samples.php) has four links to show
sample work. I would like these links to open new...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |