Satchel
Satchel

Reputation: 16724

How do I get a JavaScript popup to come without clicking link?

I am using some pre-written JavaScript from polldaddy.

They have a JavaScript option which, when you click on the link, the survey pops up as an overlay to my site.

However, I would like when people come to the site, the overlay comes up on its own without needing to click on the link.

Here is the JavaScript:

<script language="javascript" type="text/javascript">
var PDF_surveyID = 'F1B4CE39FE1ECE86';
 var PDF_openText = 'View Survey';
</script>
<script type="text/javascript" language="javascript" src="http://www.polldaddy.com/s.js"></script>
<noscript><a href="http://surveys.polldaddy.com/s/F1B4CE39FE1ECE86/">View Survey</a></noscript>

Upvotes: 0

Views: 745

Answers (2)

lc.
lc.

Reputation: 116458

Looking at http://www.polldaddy.com/s.js, the link is written is in the following statement:

document.write('<a href="javascript:PDF_launch(\''+ PDF_surveyID +'\');">'+ PDF_openText +'</a>');

So when you click on the link, it's calling

PDF_launch(PDF_surveyID);

What you'll want to do is call this yourself when the page loads. For example:

<body onload="PDF_launch(PDF_surveyID)">

Upvotes: 1

Jim Puls
Jim Puls

Reputation: 81082

If you look at the script you're including, you'll see it does this:

document.write('<a href="javascript:PDF_launch(\''+ PDF_surveyID +'\');">'+ PDF_openText +'</a>');

to put the link into the page. What you'll want to do, then, is call PDF_launch when the page loads.

Upvotes: 2

Related Questions