473,549 Members | 3,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript window.open fails in IE

I have been searching the 'Net, and I can't find the right solution
here. I am writing some PHP pages that utilize some Javascript. The
script works in Mozilla/Netscape, but fails in IE. I don't know if
it's the Javascript or the PHP that is causing the problem. I started
with an example in a book and added on.

The script I'm using is:

<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
<!--
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record Viewer", "toolbar=no,wid th=<?php
echo $new_win_width ?>,height=<?ph p echo new_win_height
?>,directories= no,status=no,sc rollbars=yes,re sizable=yes,men ubar=no");
NEW_WIN.locatio n.href = url;
}

//-->
</SCRIPT>

(I added some line break to make it readable The NEW_WIN line is all
on one line.)

The PHP variables get added correctly, and the two calls from the PHP
program are similar to:

<a
href="javascrip t:open_window(' $PHP_SELF?actio n=action1');\"> Action1</a>

or an

echo "<button
onClick=\"javas cript:open_wind ow('$PHP_SELF?a ction=insert_re cord');\" >
Insert new record</button>";

These work fine in Netscape/Mozilla, but in IE, after clickng a bunch
of times, I get "Domain not found". I've replaced PHP_SELF with the
full URL to test, and it still fails. I know that the scripting is
turned on in IE becuase I can go to example sites and the window.open
function works.

Any ideas as to what's going on here?

Sep 19 '05 #1
9 3437
gl*******@gmail .com said the following on 9/19/2005 4:11 PM:
I have been searching the 'Net, and I can't find the right solution
here. I am writing some PHP pages that utilize some Javascript. The
script works in Mozilla/Netscape, but fails in IE. I don't know if
it's the Javascript or the PHP that is causing the problem. I started
with an example in a book and added on.

The script I'm using is:

<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
<!--
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record Viewer", "toolbar=no,wid th=<?php
IE is known not to handle window names with spaces in them real well.
Change it to "RecordView er" or "Record_Vie wer"
echo $new_win_width ?>,height=<?ph p echo new_win_height
?>,directories= no,status=no,sc rollbars=yes,re sizable=yes,men ubar=no");
NEW_WIN.locatio n.href = url;
}

//-->
</SCRIPT>
Post the code that gets sent to the browser, not the PHP code that
generates it. And why are you opening a blank window and then setting
it's href property? Just specify the URL in the window.open call:

window.open(url ,"Record Viewer",.....)
<a
href="javascrip t:open_window(' $PHP_SELF?actio n=action1');\"> Action1</a>


http://jibbering.com/faq/#FAQ4_24

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 19 '05 #2
<gl*******@gmai l.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
I have been searching the 'Net, and I can't find the right solution
here. I am writing some PHP pages that utilize some Javascript. The
script works in Mozilla/Netscape, but fails in IE. I don't know if
it's the Javascript or the PHP that is causing the problem. I started
with an example in a book and added on.

The script I'm using is:

<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
<!--
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record Viewer", "toolbar=no,wid th=<?php
echo $new_win_width ?>,height=<?ph p echo new_win_height
?>,directories= no,status=no,sc rollbars=yes,re sizable=yes,men ubar=no");
NEW_WIN.locatio n.href = url;
}

//-->
</SCRIPT>

(I added some line break to make it readable The NEW_WIN line is all
on one line.)

The PHP variables get added correctly, and the two calls from the PHP
program are similar to:

<a
href="javascrip t:open_window(' $PHP_SELF?actio n=action1');\"> Action1</a>

or an

echo "<button
onClick=\"javas cript:open_wind ow('$PHP_SELF?a ction=insert_re cord');\" >
Insert new record</button>";

These work fine in Netscape/Mozilla, but in IE, after clickng a bunch
of times, I get "Domain not found". I've replaced PHP_SELF with the
full URL to test, and it still fails. I know that the scripting is
turned on in IE becuase I can go to example sites and the window.open
function works.

Any ideas as to what's going on here?

I tested with this variation:

<html>
<head>
<title>js_php.h tm</title>
<script type="text/javascript">
function open_window(url ) {
var cfg = "width=<?ph p echo $new_win_width ?>,"
cfg += "height=<?p hp echo new_win_height ?>,";
cfg += "scrollbars=yes ,resizable=yes"
var win = window.open ("","Record Viewer",cfg);
win.location.hr ef = url;
}
</script>
</head>
<body onload="open_wi ndow('http://www.google.com/')">
</body>
</html>

and it didn't work for me under IE (5.5) either.

My guess is that IE doesn't interpret inline php.
Sep 19 '05 #3
McKirahan said the following on 9/19/2005 5:56 PM:
<gl*******@gmai l.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
I have been searching the 'Net, and I can't find the right solution
here. I am writing some PHP pages that utilize some Javascript. The
script works in Mozilla/Netscape, but fails in IE. I don't know if
it's the Javascript or the PHP that is causing the problem. I started
with an example in a book and added on.

The script I'm using is:

<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
<!--
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record Viewer", "toolbar=no,wid th=<?php
echo $new_win_width ?>,height=<?ph p echo new_win_height
?>,directorie s=no,status=no, scrollbars=yes, resizable=yes,m enubar=no");
NEW_WIN.locat ion.href = url;
}

//-->
</SCRIPT>

(I added some line break to make it readable The NEW_WIN line is all
on one line.)

The PHP variables get added correctly, and the two calls from the PHP
program are similar to:

<a
href="javascr ipt:open_window ('$PHP_SELF?act ion=action1');\ ">Action1</a>

or an

echo "<button
onClick=\"jav ascript:open_wi ndow('$PHP_SELF ?action=insert_ record');\" >
Insert new record</button>";

These work fine in Netscape/Mozilla, but in IE, after clickng a bunch
of times, I get "Domain not found". I've replaced PHP_SELF with the
full URL to test, and it still fails. I know that the scripting is
turned on in IE becuase I can go to example sites and the window.open
function works.

Any ideas as to what's going on here?


I tested with this variation:

<html>
<head>
<title>js_php.h tm</title>
<script type="text/javascript">
function open_window(url ) {
var cfg = "width=<?ph p echo $new_win_width ?>,"
cfg += "height=<?p hp echo new_win_height ?>,";
cfg += "scrollbars=yes ,resizable=yes"
var win = window.open ("","Record Viewer",cfg);
win.location.hr ef = url;
}
</script>
</head>
<body onload="open_wi ndow('http://www.google.com/')">
</body>
</html>

and it didn't work for me under IE (5.5) either.

My guess is that IE doesn't interpret inline php.


Since php is processed on the server (with an exception and that is a
plugin that allows php to be clientside), whether IE interprets it or
not is totally dependent on whether PHP is enabled on the server. Try
changing your window name to no spaces, remove the PHP code, and see
what happens.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Sep 19 '05 #4
gl*******@gmail .com a écrit :
I have been searching the 'Net, and I can't find the right solution
here. I am writing some PHP pages that utilize some Javascript. The
script works in Mozilla/Netscape, but fails in IE. I don't know if
it's the Javascript or the PHP that is causing the problem. I started
with an example in a book and added on.

The script I'm using is:

<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
language attribute is deprecated.
<!--
HTML comment is not needed here.
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record Viewer", "toolbar=no,wid th=<?php
Right here. The window name should be a one string without blank space.

http://developer.mozilla.org/en/docs/DOM:window.open

echo $new_win_width ?>,height=<?ph p echo new_win_height
?>,directories= no,status=no,sc rollbars=yes,re sizable=yes,men ubar=no")
If the windowFeatures string list is not empty, then you only need to
set the features which will be on, enabled.

; NEW_WIN.locatio n.href = url;
I never understood why people code like that. Why not define the url in
the window.open() call?
}

//-->
</SCRIPT>

(I added some line break to make it readable The NEW_WIN line is all
on one line.)

The PHP variables get added correctly, and the two calls from the PHP
program are similar to:

<a
href="javascrip t:open_window(' $PHP_SELF?actio n=action1');\"> Action1</a>

"javascript :" pseudo-protocol is definitely not recommendable.

http://jibbering.com/faq/#FAQ4_24

http://developer.mozilla.org/en/docs.....29.22_....3E
"
* "javascript :" pseudo-links become dysfunctional when javascript
support is disabled or inexistent. Several corporations allow their
employees to surf on the web but under strict security policies: no
javascript enabled, no java, no activeX, no Flash. For various reasons
(security, public access, text browsers, etc..), about 8% to 12% of
users on the web surf with javascript disabled.
* "javascript :" links will interfere with advanced features in
tab-capable browsers: eg. middle-click on links, Ctrl+click on links,
tab-browsing features in extensions, etc.
* "javascript :" links will interfere with the process of indexing
webpages by search engines.
* "javascript :" links also interfere with assistive technologies
and several web-aware applications (e.g. PDA).
* Protocol scheme "javascript :" will be reported as an error by
link validators and link checkers.
"

Gérard
--
remove blah to email me
Sep 20 '05 #5
McKirahan a écrit :
var win = window.open ("","Record Viewer",cfg);
var win = window.open (url, "RecordView er", cfg);

will work without a problem.
win.location.hr ef = url;
}
</script>
</head>
<body onload="open_wi ndow('http://www.google.com/')">

Well, first of all, don't try on an onload event.

</body>
</html>

and it didn't work for me under IE (5.5) either.


Remove the blank space between the word Record and Viewer.

http://developer.mozilla.org/en/docs/DOM:window.open

Gérard
--
remove blah to email me
Sep 20 '05 #6
Thanks to all the suggestions. It turned to be the space in the window
name.

To be complete, here is the code that is sent to the browser (minus the

PHP, and after the change to an "_" in the window name):

<HTML>
<HEAD>
<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
<!--
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record_Viewer" ,
"toolbar=no,wid th=850,height=5 75,directories= no,status=no,sc rollbars=yes,re sizable=yes,men ubar=no");
NEW_WIN.locatio n.href = url;
}

//-->
</SCRIPT>

I made an example page to test an inline href javascript call like I
listed in the code above, and a full url. Those continued to fail in
IE, but after replacing the space with an underscore, all of the links
worked. I can't belive it's something that simple as a space.

Thanks! This has been racking my brain for about a week!

Sep 20 '05 #7
G-Man wrote:
Thanks to all the suggestions. It turned to be the space in the window
name.

To be complete, here is the code that is sent to the browser (minus the

PHP, and after the change to an "_" in the window name):

<HTML>
<HEAD>
<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
<!--
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record_Viewer" ,
"toolbar=no,wid th=850,height=5 75,directories= no,status=no,sc rollbars=yes,re sizable=yes,men ubar=no");
NEW_WIN.locatio n.href = url;
}

//-->
</SCRIPT>

You have ignored some good advice, here's how I would do it:
<SCRIPT TYPE="text/javascript">
function open_window(url ) {
var NEW_WIN = null;//questionable
NEW_WIN =
window.open(url ,"Record_Viewer ","width=850,he ight=575,scroll bars,resizable" );
}
</SCRIPT>
Sep 20 '05 #8
G-Man a écrit :
Thanks to all the suggestions. It turned to be the space in the window
name.

To be complete, here is the code that is sent to the browser (minus the

PHP, and after the change to an "_" in the window name):

<HTML>
<HEAD>
<SCRIPT LANGUAGE="Javas cript" TYPE="text/javascript">
Again, why do you use language? language is deprecated.
<!--
Why do you need to comment the HTML code? It's not needed anymore.
function open_window(url ) {
var NEW_WIN = null;
NEW_WIN = window.open ("", "Record_Viewer" ,
"toolbar=no,wid th=850,height=5 75,directories= no,status=no,sc rollbars=yes,re sizable=yes,men ubar=no");
NEW_WIN.locatio n.href = url;
Why not insert the url in the 1st parameter of the window.open()
function? instead of adding another instructions just to do that...
You do not need to set the config parameters to no once there is at
least 1 parameter defined.
You set the height to 575 but this will not be carried out by a large
majority of browsers (even users with a 1024x768 scr.res.) because there
won't be enough height on the user workarea for applications. So, your
code will trigger error correction mechanisms in MSIE 6, Mozilla-based
browsers and most likely other browsers.

Thanks! This has been racking my brain for about a week!

Everything was already mentioned at this page:

http://developer.mozilla.org/en/docs..._DOM_Reference

along with best recommendations , examples, etc..

Gérard
--
remove blah to email me
Sep 21 '05 #9
Mick White a écrit :
<SCRIPT TYPE="text/javascript">
function open_window(url ) {
var NEW_WIN = null;//questionable
You're absolutely correct. Declaring NEW_WIN as a local variable is
useless and pointless. It should be a global variable.
NEW_WIN =
window.open(url ,"Record_Viewer ","width=850,he ight=575,scroll bars,resizable" );

}
</SCRIPT>


Gérard
--
remove blah to email me
Sep 21 '05 #10

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

Similar topics

0
7446
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7718
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6041
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.