By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

problem with popups.

P: n/a
Hi, I tried to follow the tutorial on htmlsource.com, but even if I copy and
paste it, I still can't get a window to popup. Is there something wrong with
this code?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html;
charset=windows-1252">
<title>
Music
</title>
<link rel="STYLESHEET" href="virtue.css" type="text/css">

</head>
<body>

<script type="text/javascript">
<!--
var newwindow;
function poptastic(url)
{
newwindow=PrivoxyWindowOpen(url,'name','height=400 ,width=300');
if (window.focus) {newwindow.focus()}
}
// -->
</script>

<p>
Would you like to see <a
href="javascript:poptastic('/chords.html');">
chords</a> or lyrics?
</p>

</body>
</html>
Jan 14 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"Colin MacIntyre" <co***@clanmacintyre.ca> wrote in message
news:43***********************@taz.nntpserver.com. ..
Hi, I tried to follow the tutorial on htmlsource.com, but even if I copy and paste it, I still can't get a window to popup. Is there something wrong with this code?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html;
charset=windows-1252">
<title>
Music
</title>
<link rel="STYLESHEET" href="virtue.css" type="text/css">

</head>
<body>

<script type="text/javascript">
<!--
var newwindow;
function poptastic(url)
{
newwindow=PrivoxyWindowOpen(url,'name','height=400 ,width=300');
if (window.focus) {newwindow.focus()}
}
// -->
</script>

<p>
Would you like to see <a
href="javascript:poptastic('/chords.html');">
chords</a> or lyrics?
</p>

</body>
</html>


Is '/chords.html' in the root of the Web server invoking it?

If not then use a fully qualified URL.
Jan 14 '06 #2

P: n/a
Colin MacIntyre wrote:
Hi, I tried to follow the tutorial on htmlsource.com, but even if I copy and
paste it, I still can't get a window to popup. Is there something wrong with
this code?
Do you get an error message? If so, what is it? Is it something like
"PrivoxyWindowOpen is note defined"?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html;
charset=windows-1252">
<title>
Music
</title>
<link rel="STYLESHEET" href="virtue.css" type="text/css">

</head>
<body>

<script type="text/javascript">
<!--
Don't use HTML comment delimiters inside script elements, they serve no
useful purpose and are potentially harmful.

var newwindow;
function poptastic(url)
{
newwindow=PrivoxyWindowOpen(url,'name','height=400 ,width=300');
What does PrivoxyWindowOpen() do? Where is it defined?

if (window.focus) {newwindow.focus()}
}
// -->
</script>

<p>
Would you like to see <a
href="javascript:poptastic('/chords.html');">
chords</a> or lyrics?


Using the javascript pseudo-protocol in the href attribute of an A element
is known to have unusual side-effects in some browsers. It also means that
users without script see a 'link' that does nothing. Instead, put a real
URL in the href and use an onclick attribute to open the popup.
<p>Would you like to see <a
href="/chords.html"
onclick="poptastic('/chords.html');return false;">chords</a>
or lyrics?</p>
Adding return false to the onclick means that if scripting is enabled, the
link won't be followed. Some popup blockers may still stop your script
from opening a popup however.
[...]

--
Rob
Jan 15 '06 #3

P: n/a
That meta tag from Dreamweaver I think, has caused problems with me,
try deleting it.

Jan 15 '06 #4

P: n/a
mo********@gmail.com said the following on 1/14/2006 8:34 PM:
That meta tag from Dreamweaver I think
This one that you didn't bother quoting?

<meta http-equiv="CONTENT-TYPE" content="text/html;
charset=windows-1252">

That is *not* a "DreamWhacker" meta tag. It is a very standard version
of a meta tag in fact.
has caused problems with me, try deleting it.


Such as?

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

P: n/a
On 2006-01-14, Colin MacIntyre <co***@clanmacintyre.ca> wrote:
Hi, I tried to follow the tutorial on htmlsource.com, but even if I copy and
paste it, I still can't get a window to popup. Is there something wrong with
this code?

newwindow=PrivoxyWindowOpen(url,'name','height=400 ,width=300');


you need to paste the code for PrivoxyWindowOpen also.

if you want it to work in more browsers give the <a> a taget that
matches 'name' above.

Bye.
Jasen
Jan 15 '06 #6

P: n/a
RobG wrote:
Colin MacIntyre wrote:
Hi, I tried to follow the tutorial on htmlsource.com, but
even if I copy and paste it, I still can't get a window to
popup. Is there something wrong with this code?


Do you get an error message? If so, what is it? Is it
something like "PrivoxyWindowOpen is note defined"?

<snip>
var newwindow;
function poptastic(url)
{
newwindow=PrivoxyWindowOpen(url,'name','height=400 ,width=300');


What does PrivoxyWindowOpen() do? Where is it defined?


The name "PrivoxyWindowOpen" brings to mind a content
inserting/re-writing proxy of the 'Internet Security'/Add blocking type.
These often work by replacing the character sequence "window.open" with
a reference to an alternative 'window opening' (or, not opening)
function that it has previously inserted into the page. Obviously these
proxies need to work quickly and so probably do not restrict their
actions to contexts within the original source where javascript can be
expected to be found. Rather; replacing any sequences of characters that
correspond with the offending sequence wherever they are found in a
page.

If the OP is using (knowingly or otherwise) such a proxy while
attempting to view examples of javascript code (from tutorial and the
like) then original sequences of characters that correspond with
sequences that the proxy is set-up to filter will also be replaced. So,
while the original code may say 'window.open' (as would be expected in
the example shown) the OP may only be in a position to view it in its
modified state.

There is a certain irony in attempting to learn how to use javascript to
open new windows while operating the sort of software that contributes
to rendering the practice non-viable.
if (window.focus) {newwindow.focus()}

<snip>

I am surprised you didn't also find fault with that particularly
irrational construct. ;)

Richard.
Jan 15 '06 #7

P: n/a
Boy did I laugh when I read this! You're absolutely right, Privoxy (an IP
anonymizer and load/exit popup blocker) was automatically replacing the
code. Still, while using it, I can go to cnews.canoe.ca, or any other site
that offers a popup and it works fine. But try to do the same myself?
Nothing. Absolutely nothing. I exit Privoxy, replace the code with
window.open, still nothing. I try the 'onclick' suggestion, delete the
comment delimiters, nothing. /chords.html is in the same folder I'm testing
the page from. I also tried putting '/html/chords.html' thinking it might be
seeing the disk root as the root.

Testing with Firefox and IE by the way. IE does give a page error saying,
Line 1 Char 1 Error: Object expected Code: 0. Not sure what this means.

Thanks for the suggestions so far, I'm just pounding my head against the
desk over this one.
Jan 15 '06 #8

P: n/a
It just didnt work...... it completely failed,m also how do you quote
text?

Jan 15 '06 #9

P: n/a
mo********@gmail.com said the following on 1/15/2006 1:40 PM:
It just didnt work...... it completely failed,m also how do you quote
text?


If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

That is a ready-made answer I have for Google users that explains how to
quote text using groups.google.com to post.

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

P: n/a
Colin MacIntyre wrote:
Boy did I laugh when I read this! You're absolutely right, Privoxy (an IP
anonymizer and load/exit popup blocker) was automatically replacing the
code. Still, while using it, I can go to cnews.canoe.ca, or any other site
that offers a popup and it works fine. But try to do the same myself?
Nothing. Absolutely nothing. I exit Privoxy, replace the code with
window.open, still nothing. I try the 'onclick' suggestion, delete the
comment delimiters, nothing. /chords.html is in the same folder I'm testing
the page from.
The path /chords.html is, depending on the context, either the root of
your disk drive (roughly equivalent to c: in Windows) or the root of
your web domain. It is almost never the current folder.

Either remove the '/', add a leading dot './' to get the current
directory (i.e. use './chords.html') or use a full path including the
protocol. e.g. for a local file on Windows you might have:

file:///C:/Documents%20and%20Settings/yourUserID/webstuff/chords.html
The most common approach is to either remove the slash '/'.

I also tried putting '/html/chords.html' thinking it might be
seeing the disk root as the root.
That may work if chords.html is in a folder called 'html' which is at
the root of the same disk volume.

Testing with Firefox and IE by the way. IE does give a page error saying,
Line 1 Char 1 Error: Object expected Code: 0. Not sure what this means.


IE error messages are usually vague and often misleading, use the
Firefox JavaScript console - what does it report? It's not perfect, but
generally more helpful than IE.

[...]

--
Rob
Jan 15 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.