php - Open external link in iframe using drop down menu -


i using php read text file , generate dropdown menu open link in new tab when option selected

<select onchange="window.location.href=this.value"> <?php if ($file = @fopen('data-receive.txt', 'r')) { while(($line = fgets($file)) !== false) { echo "<option style='width:100px;' value='http://{$line}'>{$line}</option>"; } fclose($file); } ?> </select> 

this works , opens selected website in new tab.

however, have iframe on page , drop down menu option open in iframe instead of new tab

<iframe src="demo.html" name="test-frame" width="100%" height="500px"></iframe> 

is possible? appreciated or sms me

** solved ** changed

window.href.location  

to

frames['test-frame'].location.href 

source: http://konus.biz/books/dhtml/%d3%f7%e5%e1%ed%e8%ea%20js%20%ee%f2%20quirksmode/iframe.html#

<select id="changeiframe"> <?php if ($file = @fopen('data-receive.txt', 'r')) { while(($line = fgets($file)) !== false) { echo "<option style='width:100px;' value='http://{$line}'>{$line}</option>"; } fclose($file); } ?> </select> 

ifarme:

<iframe id="sourceiframe" src="demo.html" name="test-frame" width="100%" height="500px"></iframe> 

javascript:

var iframe = document.getelementbyid("sourceiframe"); var changeiframe= document.getelementbyid("changeiframe");  changeiframe.onchange = function() {     iframe.src = this.value; } 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -