Language: PHP and jQuery
What I’m trying to do is pop up a dynamic link when a user clicks on it.
I don’t want the page to be opened in a new window though, but in a modal one which overlays on the current page.
So with javascript, when a user clicks on this link, the action is to find the link’s attr href and make a code for THAT link to be inside an iframe within the modal window.
The HTML with dynamic PHP link:
<a href="http://www.facebook.com/share.php?u=<?php echo $root_url; ?>?id=<?php echo $rows['id']; ?>&title=<?php echo urlencode($rows['keyword']); ?>" style="border: none;" onclick="return false;" class="fblink" target="iframe"><img src="./img/Facebook.png" style="float: right; margin-top: 0px;" title="Share on Facebook" alt="Share on Facebook" id="<?php echo $rows['id']; ?>"></a>
The jQuery script:
var makePop = function() {
link = $(this).attr('href');
return '<div class="the_box" id="box" style="display: block;"><a class="boxclose" id="boxclose"></a>
<iframe src="' + link + '" height="500px" width="600px" id="" name="iframe"></iframe></div>';
} // End of Function.
$("a.fblink").click(makePop);
I don’t know how to make this happen… This is not working.
Anybody? :o)
The following should provide what your looking for. However would need to consider issues such as same origin policy for the XHR ‘load’ call.
See example at: http://jsfiddle.net/qeXea/2/
Note: Due to same origin policy the iframe isn’t able to populate with the content, simply setup your own page on your website and use your own urls to view.
HTML
CSS
Alternative
HTML