Note that there are some explanatory texts on larger screens.

plurals
  1. POFind attr('href') and open inside hidden iframe on the page, then show() iframe (jQuery + PHP)
    text
    copied!<p>Language: <strong>PHP and jQuery</strong></p> <p>What I'm trying to do is pop up a dynamic link when a user clicks on it.<br> 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.</p> <p>So with javascript, when a user clicks on this link, the action is to find the link's attr <code>href</code> and make a code for THAT link to be inside an iframe within the modal window.</p> <p>The <strong>HTML</strong> with dynamic PHP link: </p> <pre class="lang-html prettyprint-override"><code> &lt;a href="http://www.facebook.com/share.php?u=&lt;?php echo $root_url; ?&gt;?id=&lt;?php echo $rows['id']; ?&gt;&amp;title=&lt;?php echo urlencode($rows['keyword']); ?&gt;" style="border: none;" onclick="return false;" class="fblink" target="iframe"&gt;&lt;img src="./img/Facebook.png" style="float: right; margin-top: 0px;" title="Share on Facebook" alt="Share on Facebook" id="&lt;?php echo $rows['id']; ?&gt;"&gt;&lt;/a&gt; </code></pre> <p>The <strong>jQuery script</strong>: </p> <pre class="lang-js prettyprint-override"><code> var makePop = function() { link = $(this).attr('href'); return '&lt;div class="the_box" id="box" style="display: block;"&gt;&lt;a class="boxclose" id="boxclose"&gt;&lt;/a&gt; &lt;iframe src="' + link + '" height="500px" width="600px" id="" name="iframe"&gt;&lt;/iframe&gt;&lt;/div&gt;'; } // End of Function. $("a.fblink").click(makePop); </code></pre> <p>I don't know how to make this happen... This is not working.<br> Anybody? <strong>:o)</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload