Reputation: 11
Noob here... attempting to display an iframe inside of a javascript popup upon a user's exit. The iframe should be seen first (within the browser prompt) and should allow the user to submit their email address.
I've had some success referencing this idea, but realized the iframe is only displayed after the user has elected to stay on the page. Here's what I'd like to do with the code:
function PopIt() {
$("a#trigger").trigger('click');
window.onbeforeunload = UnPopIt;
return <iframe src="http://moneymappress.com/pro/su/pop_signup2.html">Your Browser doesn't support iframes</iframe>;
}
After reading up on some of the security issues with iframes and javascript it appears this could be an issue, but I wanted to get a second opinion. I'm, also aware the code wouldn't work as is, but figured it was the easiest way to communicate
If it's the case that an iframe can't be displayed with, what would the next best option be?
Thanks for your help!
Upvotes: 0
Views: 211
Reputation: 74146
You can't do this with the onbeforeunload
:
window.onbeforeunload = funcRef
funcRef
is a reference to a function or a function expressionThe function should assign a string value to the returnValue property of the Event object and return the same string
Notes
- When this event returns a non-void value, the user is prompted to confirm the page unload. In most browsers, the return value of the event is displayed in this dialog.
So that's the reason that on the example you've referenced the prompt is shown first.
Upvotes: 1