/    Sign up×
Community /Pin to ProfileBookmark

2 Popup Problem

Hello –

My goal is to have 1 popup show up when the user exits the site (on unload) and also allow other popup boxes to show up when the user clicks on the “about us” or “faq” links.

For some reason when the “about us” html link is clicked I get a script error. This started happening after I added the “on unload” popup.

This first chunk of code contains the reference to the “on unload” popup script, and then underneath has the popup script for clicked html links.

[COLOR=blue]<SCRIPT LANGUAGE=”javascript” SRC=”/popupscript.js”></SCRIPT>
<script language=”javascript”>
var newwindow;
function poptastic(url)
{
newwindow=window.open(url,’name’,’height=450,width=425,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1′);
if (window.focus) {newwindow.focus()}
}
</script>
[/COLOR]

Next, here is the contents of the popupscript.js file (this is the script that opens the popup on unload if the varible OPEN = 1

[COLOR=blue]var open=1;
function openw()
{
open=1;

}
function unopen()
{
open=0;
return true;
}
function createwin()
{
if (open==1)
{

window.showModalDialog(“http://www.eveningfishing.com/new_product.htm”,””,”dialogHeight: 800px; dialogWidth: 455px; dialogTop: 100px; dialogLeft: 100px; edge: Raised; center: No; help: No; resizable: Yes; status: no;”);
}
}[/COLOR]

Finally, here is the HTML code for the “about us” link which should open a popup using the “poptastic” code above.

[COLOR=blue]<a href=”javascript:poptastic(‘/sub/aboutus.htm’);” onclick=”return unopen();”>About
Us</a>[/COLOR]

For some reason I get a javascript error when I click on the “about us” html link. The “on unload” popup works like a charm.

Are the windows clashing for some reason?

Any help would be greatly appreciated. Keep in mind that the “oncclick=return unopen{}” basically sets a flag so that the “on unload” popup won’t go.

Thanks much…

Dan

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@sciguyryanOct 09.2004 — Try this:

<i>
</i>var newwindow = window.open(url,'name','height=450,width=425,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');


You had a space after the window. And Javascript lieKs unbroken strings (All on one line).


RyanJ
Copy linkTweet thisAlerts:
@eggerdaauthorOct 09.2004 — Ah, it just came out that way when I pasted it...the code is actually on 1 line with no spaces. The "poptastic" works just fine until I add the "on unload" popup.

Anyone have any other ideas? This is driving me nuts...

Dan
Copy linkTweet thisAlerts:
@Warren86Oct 09.2004 — --------- PopUpScript.js --------

function exitMsg(){

if (exitFlag == true){window.open('ExitMsg.html')}

}

function poptastic(url){ window.open(url,'name','height=450,width=425,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');

}

--------- Main document ----------

<HTML>

<Head>

<Script Language=JavaScript Src='PopUpScript.js'></Script>

<Script>

var exitFlag = true;

function aboutUs(){

window.open('aboutUs.html');
exitFlag = false;
}

window.onunload=exitMsg;


</Script>

</Head>

<Body>

<a href=javascript:aboutUs()>About Us</a><br><br>

<a href=javascript:poptastic('someLink.html')>Popup Linkk</a>

</Body>

</HTML>

--------- AboutUs.html ------------

<HTML>

<Body>

All About Us

</Body>

</HTML>

--------- SomeLink.html -----------

<HTML>

<Body>

Some Link

</Body>

</HTML>

------- ExitMsg.html ------------

<HTML>

<Body>

Exit Message

</Body>

</HTML>
×

Success!

Help @eggerda spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...