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

J

johnsonholding

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','width=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>
 
T

Thomas 'PointedEars' Lahn

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>
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
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 1/12/2006 12:11 AM:

Irrelevant and actually counter-productive to the thread.

Again, irrelevant as the OP already stated they get an error.
Where is the corresponding open tag?

Irrelevant to the problem but a good question. Probably didn't get
snipped in a copy/paste.
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.

Irrelevant to the problem. Stick around, keep reading, you might learn
something in this post yet.

Again, irrelevant to the problem and counterproductive in the thread.

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.
 
R

Randy Webb

(e-mail address removed) 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','width=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,height=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.
 
J

johnsonholding

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,height=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!
 
T

Thomas 'PointedEars' Lahn

[...]
<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).

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
 
G

Gérard Talbot

Thomas 'PointedEars' Lahn wrote :
(e-mail address removed) 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=h...matically)&doctype=HTML+4.01+Strict&verbose=1


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
 
G

Gérard Talbot

Thomas 'PointedEars' Lahn a écrit :
(e-mail address removed) 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/val...rnings=yes&input=yes&spider=yes&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]



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=http://pointedears.de/scripts/

Gérard
 
R

Randy Webb

Thomas 'PointedEars' Lahn rambled in where he
thinks he is in 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.
[...]
<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.

Valid Reference to point out.

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.

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.
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);"

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,height=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 >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top