473,322 Members | 1,703 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,322 software developers and data experts.

Works in Firefox, but not in IE - pop up window - what did I do wrong?

Here is the code for a pop-up window that works in Firefox and not in
IE - I get a java error or something,

Here is the code :

</script>

<SCRIPT language="JavaScript" type="text/javascript">
<!-- ;
var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
newwindow.location.href = url;
newwindow.focus(); }
else {

newwindow=window.open(url,'whatsyourvice.htm','wid th=130,height=180,resizable=1');}

}

function tidy() {
if (newwindow.location && !newwindow.closed) {
newwindow.close(); }

}

// Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->
</SCRIPT>

And then :
<div align="left"><a
href="javascript:popitup('whatsyourvice.htm')"><b> <font face="Verdana,
Arial, Helvetica, sans-serif" size="1" color="#FFFF00">Click
here for <br>"What's Your
Vice?</font></b></a></div>

Jan 12 '06 #1
8 2452
jo************@yahoo.com wrote:
Here is the code for a pop-up window that works in Firefox and not in
IE - I get a java error or something,
<URL:http://jibbering.com/faq/#FAQ2_2>
<URL:http://jibbering.com/faq/#FAQ4_43>
Here is the code :

</script>
Where is the corresponding open tag?
<SCRIPT language="JavaScript" type="text/javascript">
<!-- ;
Replace the above lines with

<script type="text/javascript">

Explanations can be found in the archives.
[...]
// Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->
So you should ask him first.
[...]
<div align="left"><a
href="javascript:popitup('whatsyourvice.htm')"><b> <font face="Verdana,
Arial, Helvetica, sans-serif" size="1" color="#FFFF00">Click
here for <br>"What's Your
Vice?</font></b></a></div>


<URL:http://jibbering.com/faq/#FAQ4_24>
<URL:http://validator.w3.org/>
<URL:http://www.w3.org/QA/Tips/>
HTH

PointedEars
Jan 12 '06 #2
Thomas 'PointedEars' Lahn said the following on 1/12/2006 12:11 AM:
jo************@yahoo.com wrote:

Here is the code for a pop-up window that works in Firefox and not in
IE - I get a java error or something,

<URL:http://jibbering.com/faq/#FAQ2_2>


Irrelevant and actually counter-productive to the thread.
<URL:http://jibbering.com/faq/#FAQ4_43>
Again, irrelevant as the OP already stated they get an error.
Here is the code :

</script>

Where is the corresponding open tag?


Irrelevant to the problem but a good question. Probably didn't get
snipped in a copy/paste.
<SCRIPT language="JavaScript" type="text/javascript">
<!-- ;

Replace the above lines with

<script type="text/javascript">

Explanations can be found in the archives.


For someone who doesn't appear to like Google and it's URL's, you like
to blankly refer to it a lot.
[...]
// Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->

So you should ask him first.

[...]
<div align="left"><a
href="javascript:popitup('whatsyourvice.htm')">< b><font face="Verdana,
Arial, Helvetica, sans-serif" size="1" color="#FFFF00">Click
here for <br>"What's Your
Vice?</font></b></a></div>

<URL:http://jibbering.com/faq/#FAQ4_24>


Finally, something slightly of help to the OP.
<URL:http://validator.w3.org/>
Irrelevant to the problem. Stick around, keep reading, you might learn
something in this post yet.
<URL:http://www.w3.org/QA/Tips/>
Again, irrelevant to the problem and counterproductive in the thread.
HTH


It didn't. But that is typical of most advice given by you.
Solution: IE doesn't like the period in the Window name parameter to the
window.open call.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 12 '06 #3
jo************@yahoo.com said the following on 1/11/2006 11:29 PM:
Here is the code for a pop-up window that works in Firefox and not in
IE - I get a java error or something,

Here is the code :

</script>

<SCRIPT language="JavaScript" type="text/javascript">
<!-- ;
var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
newwindow.location.href = url;
newwindow.focus(); }
else {

newwindow=window.open(url,'whatsyourvice.htm','wid th=130,height=180,resizable=1');}

}

function tidy() {
if (newwindow.location && !newwindow.closed) {
newwindow.close(); }

}

// Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->
</SCRIPT>

And then :
<div align="left"><a
href="javascript:popitup('whatsyourvice.htm')"><b> <font face="Verdana,
Arial, Helvetica, sans-serif" size="1" color="#FFFF00">Click
here for <br>"What's Your
Vice?</font></b></a></div>


Ditch every bit of that code, it is utterly useless.

<script type="text/javascript">
var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
newwindow.location.href = url;
newwindow.focus(); }
else {
newwindow=window.open(url,'myWindow','width=130,he ight=180,resizable=1');}
}
</script>
<a href="URLToFile" onclick="popitup(this.href);return false">Click here
for <br>What's Your Vice?</a>

The initial problem with IE is that it didn't like the period in the
second parameter to window.open. You had 'whatsyourvice.htm' and once
the period was removed it started semi-working in IE in that it solved
the errors.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 12 '06 #4
Thanks for the help Randy. I am not anywhere near understanding
Javascript, so I wil ltake it from you that the code is better off
dead. I will cut and paste you new code :

<script type="text/javascript">
var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
newwindow.location.href = url;
newwindow.focus(); }
else {
newwindow=window.open(url,'myWindow','width=130,he ight=180,resizable=1');}
}
</script>
<a href="URLToFile" onclick="popitup(this.href);return false">Click here
for <br>What's Your Vice?</a>

The initial problem with IE is that it didn't like the period in the
second parameter to window.open. You had 'whatsyourvice.htm' and once
the period was removed it started semi-working in IE in that it solved
the errors.


Oh well, I will try to cut and paste what you have - now my question is
- where do I put the name of the url I want opened? Do I need to put
'.htm' with the url name (after you show me where to put it)?
Also I noticed you script is alot neater and tidier, that will be
better for me because I hope to try and understand it all! So, if you
could just direct me to where I put the url information in the script,
I shold be on my way. Thank you!

Jan 12 '06 #5
jo************@yahoo.com wrote:
[...]
<script type="text/javascript">
Please provide attribution of quoted material. Usenet is not a (1:1)
chat, by default people all over the planet read what you write.

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
<URL:http://groups.google.com/support/bin/answer.py?answer=14213&query=quote&topic=0&type=f>

Therefore, it also does not make much sense to address only one specific
person in your postings (with rare exceptions).

<URL:http://en.wikipedia.org/wiki/Usenet>
var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
newwindow.location.href = url;
newwindow.focus(); }
else {
newwindow=window.open(url,'myWindow','width=130,he ight=180,resizable=1');} }
</script>
<a href="URLToFile" onclick="popitup(this.href);return false">Click here
for <br>What's Your Vice?</a>

The initial problem with IE is that it didn't like the period in the
second parameter to window.open. You had 'whatsyourvice.htm' and once
the period was removed it started semi-working in IE in that it solved
the errors.
Oh well, I will try to cut and paste what you have - now my question is
- where do I put the name of the url I want opened?


It has to be the first argument of window.open(), so you should pass it for
the only argument of popitup(), as that is used there in the window.open()
call.

In the `onclick' attribute value of the `a' element, this is `this.href'
which refers to the `href' attribute value of that `a' element (to be
exact: the element that fired the event, which happens to be that `a'
element here). So you should replace `URLToFile' with the URL of the
resource you want displayed in the popup or in the current window, if
client-side JS is not supported.

However, as I already pointed out, the above code is not sufficient. A
popup blocker may prevent opening a new window, yet the event is canceled
anyway (through `return false'). And it will fail if the focus() method
is not supported for Window objects. Therefore, use the following instead:

function isMethodType(s)
{
return (s == "function" || s == "object");
}

var newwindow = '':
function popitup(url)
{
if (newwindow.location && !newwindow.closed)
{
newwindow.location = url;
if (isMethodType(typeof newwindow.focus))
{
newwindow.focus();
}
}
else
{
newwindow =
window.open(url, 'myWindow', 'width=130,height=180,resizable');
}

return newwindow;
}

and in the HTML code:

<a href="URLToFile" onclick="return !popitup(this.href);"What's Your Vice?</a>
Whereas `URLToFile' should be replaced as described.
Do I need to put '.htm' with the url name [...]
That depends on the server and resource you want to access. Servers can,
and indeed should -- <URL:http://www.w3.org/QA/Tips/uri-choose> --, be
configured to do Content Negotiation, that is, to recognize what file is
the best one to use if a resource is requested that does not match a
filename.

<URL:http://httpd.apache.org/docs/1.3/content-negotiation.html>
<URL:http://httpd.apache.org/docs/2.0/content-negotiation.html>
<URL:http://httpd.apache.org/docs/2.2/content-negotiation.html>
<URL:http://support.microsoft.com/support/kb/articles/Q229/6/90.ASP>

Try the full URL without the `.htm' in the address bar; if it works as
intended, you can of course omit the `.htm' in the `href' attribute value
as well. If it does not work (so you get an access error message like
"this page cannot be displayed"), you can either include the `.htm', or
follow my recommendation to enable Content Negotiation on your server.
[...] So, if you could just direct me to where I put the url information
in the script, I shold be on my way. Thank you!


You're welcome.
PointedEars
Jan 12 '06 #6
Thomas 'PointedEars' Lahn wrote :
jo************@yahoo.com wrote:

[snipped]
<SCRIPT language="JavaScript" type="text/javascript">
<!-- ;
Replace the above lines with

<script type="text/javascript">

Explanations can be found in the archives.


You tell others not to do what you actually do yourself and have been
doing yourself during years:

Line 525
http://pointedears.de/scripts/window.html

http://validator.w3.org/check?uri=ht...rict&verbose=1

<URL:http://validator.w3.org/>
<URL:http://www.w3.org/QA/Tips/>
HTH

PointedEars


Why can't you visit those links you give to others and start applying
and complying with the advices you give to the very own website you
control then? That's what a wide majority of people call being
consequent, being coherent, practicing what you preach, complying with
your evangelism instead of denying it.

Gérard
--
remove blah to email me
Jan 12 '06 #7
Thomas 'PointedEars' Lahn a écrit :
jo************@yahoo.com wrote:

[snipped]
<SCRIPT language="JavaScript" type="text/javascript">
<!-- ;
Replace the above lines with

<script type="text/javascript">

Explanations can be found in the archives.


The markup validator can find 17 occurences of such
<script language="JavaScript"
error in your very own site, Thomas 'PointedEars' Lahn.
Anyone can verify for himself and by himself my claim here:
http://www.htmlhelp.com/cgi-bin/vali...&hidevalid=yes

Why don't you start facing your own reality for a change? Why don't you
take a break from this newsgroup and fix your very own website? Isn't
that the logical, coherent, consequent, proactive thing to do here?

[snipped]

<URL:http://validator.w3.org/>
<URL:http://www.w3.org/QA/Tips/>
HTH

PointedEars

What will it take you to finally admit and realize that you preach to
others exactly what you refuse to yourself and what you have been
refusing for years to yourself?

When validating
http://pointedears.de/scripts/
the validator will stop reporting errors and then report:
"The maximum number of errors was reached. Further errors in the
document have not been reported."

What will it take you to finally deal with your own rusted code, your
deprecated manners, to start applying to your own code your very own
nitpicking and admonishing manners?
Go ahead and for starters click this link:
http://validator.w3.org/check?uri=ht...e%2Fscripts%2F

Gérard
--
remove blah to email me
Jan 12 '06 #8
Thomas 'PointedEars' Lahn rambled in news:comp.lang.javascript where he
thinks he is in news:de.comp.lang.javascript and therefore thinks he is
the man of all men when in reality he is a hypocritical embicile who
fails to practice what he preaches but in any event he incoherently
typed the following on his computer and posted the following on the
Twelth day of January in the Year 2006 of the Proleptic Gregorian
Calender at approximately 6 hours and 11 minutes past the hour of
midnight in the MET Time Zone according to the Header sent by his
NewsReader whereby I read it at approximately 1 hour and 51 minutes past
midnight in the Eastern Standard Time Zone in the United States of
America and promptly and replying to said post:

Now, stop whining about your damn attributions.
jo************@yahoo.com wrote:

[...]
<script type="text/javascript">

Please provide attribution of quoted material. Usenet is not a (1:1)
chat, by default people all over the planet read what you write.
Only if "people all over the planet" read English, subscribe to Usenet
and to this particular Newsgroup but it's irrelevant as attribution
should be given.
<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>
Valid Reference to point out.
<URL:http://groups.google.com/support/bin/answer.py?answer=14213&query=quote&topic=0&type=f>
Irrelevant to your comments as it only explains how to quote, not to
attribute.
Therefore, it also does not make much sense to address only one specific
person in your postings (with rare exceptions).
Sure it does if you are replying to one person in particular and you can
not email them due to email restrictions placed on the email address
used by the person you are replying to.
<URL:http://en.wikipedia.org/wiki/Usenet>
What the hell that has to do with providing attribution, posting here,
or anything else other than your desire to post a URL to a Wiki eludes
me but to each his own.
var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
newwindow.location.href = url;
newwindow.focus(); }
else {

newwindow=window.open(url,'myWindow','width=130,he ight=180,resizable=1');}
}
</script>
<a href="URLToFile" onclick="popitup(this.href);return false">Click here
for <br>What's Your Vice?</a>

The initial problem with IE is that it didn't like the period in the
second parameter to window.open. You had 'whatsyourvice.htm' and once
the period was removed it started semi-working in IE in that it solved
the errors.


Oh well, I will try to cut and paste what you have - now my question is
- where do I put the name of the url I want opened?

It has to be the first argument of window.open(), so you should pass it for
the only argument of popitup(), as that is used there in the window.open()
call.

In the `onclick' attribute value of the `a' element, this is `this.href'
which refers to the `href' attribute value of that `a' element (to be
exact: the element that fired the event, which happens to be that `a'
element here).
Elements do not "fire" events, they "trigger" them.

So you should replace `URLToFile' with the URL of the resource you want
displayed in the popup or in the current window, if client-side JS is not
supported.
Absolutely and 100% agreed.

However, as I already pointed out, the above code is not sufficient.
Nowhere in either of your posts in this thread have you pointed out
anything about the "above code not being sufficient" (even though it is
insufficient).

A popup blocker may prevent opening a new window, yet the event is canceled
anyway (through `return false').
Very valid point. But there is another potential problem with popup
blockers that your code does not deal with.
And it will fail if the focus() method is not supported for Window objects.
Can you name a UA that supports window.open but not the focus() method
of that Window object?
Therefore, use the following instead:
Don't, without corrections as it has several flaws as well.

function isMethodType(s)
{
return (s == "function" || s == "object");
}
Un-needed Function and Global Variable introduced.
var newwindow = '':
Syntax Error

Expected ';'
function popitup(url)
{
if (newwindow.location && !newwindow.closed)
Assuming the newwindow has and supports the closed property. Better
feature test for that Spock.
{
newwindow.location = url;
Assuming the newwindow supports setting the location property. Better
feature test for that Spock.
if (isMethodType(typeof newwindow.focus))
Here is the call to the unneeded Function. If all you want to do is find
out if the newwindow supports the focus, you simply test the typeof here
and no need to call a second function which will increase the overhead:

if ((typeof newwindow.focus) == 'function')
{
newwindow.focus();
}
}
else
{
newwindow =
window.open(url, 'myWindow', 'width=130,height=180,resizable');
And if a popup blocker redefines window.open to return true, your code
will fail miserably.

This is code that is inserted by Symantec (Norton):

var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
return (new Object());
}
window.open = SymWinOpen;
}

return newwindow;
}

and in the HTML code:

<a href="URLToFile" onclick="return !popitup(this.href);"
>What's Your Vice?</a>


Whereas `URLToFile' should be replaced as described.

Try this test page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<title>Form Test Page</title>
<script type="text/javascript">
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
return (new Object());
}
window.open = SymWinOpen;

var newwindow = '';
function popitup(url){
if (newwindow.location && !newwindow.closed)
{
newwindow.location = url;
if ((typeof newwindow.focus) == 'function')
{newwindow.focus();}
}
else
{newwindow=window.open(url,'myWindow','width=130,h eight=180,resizable');}
return newwindow;
}

</script>
</head>
<body>
<p>
<a href="blank2.html" onclick="return !popitup(this.href);">
What's Your Vice?</a>
</body>
</html>
And you will get no new page, no new window.

To date the best popup script I have seen or used was written by Yann
and for the life of me can't find it in the Archives or I would post it.
It even dealt with Nortons code as well.

But in the end, the best approach is one that follows something along
the lines of Richard's page:

<URL: http://www.litotes.demon.co.uk/js_info/pop_ups.html >

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 13 '06 #9

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

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
5
by: Derek Erb | last post by:
I am banging my head against the wall with this one. The following code snippets work perfectly fine in MSIE6. But produce an error in Firefox and do not work at all. BROWSER.HTM <HTML> .......
10
by: Eric-Sebastien Lachance | last post by:
Hey there, I decided to just create a 100% height and width div that filled the space over a background header image, and add an onclick event to redirect to the my index... Doesn't seem to work...
6
by: dpodkuik | last post by:
I have a simple function that does submit for me: <script language="javascript" type="text/javascript"> function sort() { //selected item value from the drop down list var...
2
by: Pugi! | last post by:
I would like to obtain the the position of backgroundimage of a div because I use it for animation. The following code works for Internet Explorer (takes the else if) and returns positionx '10px'...
4
by: John Kotuby | last post by:
Hi all... I am bulding an application and wish to use custom Modal dialog windows. According to a couple of recent articles I have seen, the newer Mozilla browsers (actually I think they said...
1
by: alvarojaviervera | last post by:
Allways I think Firefox was strong, enough ... and so far THE BEST Web- browser (That what I Think) but, now Im fighting with it, may be Im doing something wrong (of course that is what happend to...
5
by: dmk | last post by:
Hi All, function getWindowSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight =...
2
by: burtonfigg | last post by:
I'm testing an ajax page - this works fine in Firefox: http://jimpix.co.uk/clients/a/ecards/defaultx.asp Click on any of the links on the right under the 'occassions' or 'others' headings, in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.