php - Go Link thru iFrame -


i have problem , tried click link doesn't work open link using target: name of iframe. dont want use href because im going make show/hide div.

javascript:

<script type="text/javascript"> <!--// function godirect(url, targetname) { document.getelementbyid(targetname).src = url; //frame[targetname].location.href = url; } //--> </script> 

in html , php:

$a=0;  echo '<a href="#" onclick="godirect("http://www.google.com", iframe_url'.$a.');">click me!</a>';  echo '<iframe class="iframe_url" id="iframe_url'.$a.'"></iframe>'; 

you have quote strings in javascript. trying id of element passing in variable haven't defined.

you using same quote characters delimit html attribute value using delimit js strings.

to use approach using, while making minimum number of fixes make work:

echo '<a href="#" onclick="godirect(&quot;http://www.google.com&quot;, &quot;iframe_url'.$a.'&quot;);">click me!</a>'; 

using js silly idea in first place though, , implementation fails have kind of fallback when js not available (which odd, since taking steps stop browsers don't recognise script element rendering js content text).

you can plain html:

<a href="http://www.google.com"     target="iframe_url<?php echo htmlspecialchars($a); ?>">    click me! </a> 

i dont want use href because im going make show/hide div.

you can having normal, functioning link. build on things work.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -