473,399 Members | 2,774 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,399 software developers and data experts.

window.open, Linux vs. Windows

I'm a complete Javascript n00b, using a snippet I found on the web.
I'll probably be buying a Javascript book. What's the authoritative
on-line resource for Javascript, like php.net is for PHP? I'm a
relative PHP n00b.

This code works fine on Opera & Mozilla under Linux, but fails for both
Netscape & IE under Windows:

<script language="JavaScript">
<!--
function smallWindow(URL, X, Y, Title)
{
var win = window.open(URL, Title,
'width='+X+',height='+Y+',resizable=1,scrollbars=1 ');
}
// -->
</script>

<form name="form1" method="post" action="">
<html>
<head>
etc.
a ton of PHP code echoing HTML, including:

echo '<a href="javascript:onclick=smallWindow(\'unitconvert er.php\',
\'250\', \'150\', \'Convert Units\');">';
echo 'Unit Conversion Calculator';
echo '</a>';
I can open unitconverter.php stand-alone, as well as via a simple

<a href="unitconverter.php" target="new window">.

It's only when I go through Javascript that it fails with nothing more
than a friendly "Error in page" message from IE, while Netscape is mute.

--
Lynn Wallace http://www.xmission.com/~lawall
"I'm not proud. We really haven't done everything we could to protect
our customers. Our products just aren't engineered for security."
--Microsoft VP in charge of Windows OS Development, Brian Valentine.

Jul 20 '05 #1
2 3940
Raptor <me@attbi.com> writes:
I'm a complete Javascript n00b, using a snippet I found on the web.
I'll probably be buying a Javascript book. What's the authoritative
on-line resource for Javascript, like php.net is for PHP?
I don't think there is *one* authoritative reference, mainly because
there is more than one implementation of this thing called "Javascript".
I have some links at
<URL:http://www.infimum.dk/HTML/references.html#ref_1_4>
They are all more or less relevant. The first one is ofcourse the
best (the FAQ for this group :).
This code works fine on Opera & Mozilla under Linux, but fails for
both Netscape & IE under Windows:
"fails" is not a very imformative error report.

Which Netscape? Netscape 4 and Netscape 6+ are completely unrelated
browsers. In both cases, you can see Javascript errors in the Javascript
console. It is activated by entering "javascript:" in the address line.
<script language="JavaScript">
In HTML 4 and later, the type attribute is required. A Javascript
script tag is written:
<script type="text/javascript">
<!--
You don't need HTML comments in Javascript.
function smallWindow(URL, X, Y, Title)
{
var win = window.open(URL, Title,
'width='+X+',height='+Y+',resizable=1,scrollbars=1 ');
This looks reasonable (if you can accept that window.open isn't always
working at all any more - popup-blockers are getting very popular and
browsers on restricted platforms like mobile phones or WebTV can have
problems with extra windows).

No need for "var win =". It is a local variable in a function that
ends right after the assignment, so the value is lost anyway.

}
// -->
</script>

<form name="form1" method="post" action="">
<html>
<head>
You must have <html> or <head> before other HTML tags. The form
tag right before it can only exist inside the body of the HTML
page. That means that the browser inserts an implicit <body>,
and the <html> and <head> are illegal tags inside the body.

Try validating the generated HTML with, e.g., the W3C validator.
etc.
a ton of PHP code echoing HTML, including:
Generally, in this group, we only care about the HTML code that is
produced by the PHP, not the PHP code itself. If the page fails to
work, there is a bug in the HTML, and it is easier to find the bug
without the PHP around it.
echo '<a href="javascript:onclick=smallWindow(\'unitconvert er.php\',
\'250\', \'150\', \'Convert Units\');">';
The generated HTML code would be:
---
<a href="javascript:onclick=smallWindow('unitconverte r.php',
'250', '150', 'Convert Units');">Unit Conversion Calculator</a>
---
The FAQ recommends against using javascript:-URL's. Use the
onclick handler instead and put a meaningful link in the href.

You actually assign the return value of smallWindow (which is the
undefined value) to a global variable called "onclick". Maybe you
were trying to use the onclick handler?

Spaces are not allowed in window names! This can be your real problem.

I.e., use:
---
<a href="unitconverter.php" target="ConvertUnits"
onclick="smallWindow(this.href,'250','150',this.ta rget);return false;">
Unit Conversion Calculator</a>
--- I can open unitconverter.php stand-alone, as well as via a simple

<a href="unitconverter.php" target="new window">.
Don't use spaces in window names!

If you want to open a new window each time, use the target "_blank" instead.
<URL:http://www.infimum.dk/HTML/JSwindows.html#ref_3_1>
It's only when I go through Javascript that it fails with nothing more
than a friendly "Error in page" message from IE, while Netscape is
mute.


IE can give more informative error messages (not great, but better
than "Error in page"). To enable it, uncheck the option:
Tools > Options > Advanced > Browsing / Disable script debugging

Alternatively, you can install the MS Script Debugger. I am not
impressed by it, but it does show the line of the bug.

Good luck.
/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.'
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote:
This code works fine on Opera & Mozilla under Linux, but fails for
both Netscape & IE under Windows:

"fails" is not a very imformative error report.


That's all I knew at the time, being so new at this.

(Snipped) a whole heaping crapload of tremendously useful information.
Thank you very much, Lasse! :-)

I'll be looking for opportunities to pay it forward.

--
--
Lynn Wallace http://www.xmission.com/~lawall
"I'm not proud. We really haven't done everything we could to protect
our customers. Our products just aren't engineered for security."
--Microsoft VP in charge of Windows OS Development, Brian Valentine.

Jul 20 '05 #3

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

Similar topics

3
by: Edwin Boersma | last post by:
Hi, I've just installed Netscape 7.1 for Linux and the following script refuses to open a window when I call this function: function OpenLinkWindow() { ...
4
by: J Fisk | last post by:
Hi, I've been banging my head on the wall over this for about two days now so any thoughts are much appreciated. I have a static .svg file with embedded onclick="open()"'s all over. The svg...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
6
by: zdp | last post by:
Dear all: I made a window program by wxPython. Split windows, treectrl, listctrl and textctrl are used. When I program in python, the look & feel of the window controls are like the windos XP...
21
by: alistair_henderson | last post by:
Morning All, I have some code for a website which uses 'window.open' to simulate modal dialog boxes. I use the window.closed property to decide if the window object exists at various points. ...
6
by: Howard Rifkin | last post by:
Hi, I my Javascript I popup an authentication window using the command; unamePasswdWindow = open("auth.html","","width=500,height=100"); This works fine in IE, and in Firefox 2.x on...
10
by: iwl | last post by:
Hi, I tryed askstring to input some text in my script, but some ugly empty Window appears with the Input-Window behind and all together behind my Console showing my script. So all have to...
4
by: gaurav kashyap | last post by:
Dear all, I am using Microsoft Windows XP.Using putty.exe,I connected to LINUX server and a terminal window gets opened.Here i logeed in as root. What i want to do is open another terminal...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
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...
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.