Jump to content
  • Advertisement
Sign in to follow this  
agm_ultimatex

[web] javascript - simple problem (i think)

This topic is 3764 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wish to trigger a similar link to this via onClick in a textbox.
<a href="mypage.html" target="myIframe">link</a> 


The target is important, as the page i wish to link to is a layer that gets put into the iframe. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
IIRC you can just use window.open(). If you give the new window the same title as an existing open window, it will load in that window instead of opening a new window.

Share this post


Link to post
Share on other sites

<textarea id="myText"></textarea>

<iframe id="myIFrame"></iframe>

<script type="text/javascript">
var myTextElement = document.getElementById("myText");
var myIFrameElement = document.getElementById("myIFrame");

myTextElement.onclick = function() {
myIFrameElement.contentWindow.location.href = "mypage.html";
};
</script>

Share this post


Link to post
Share on other sites
Quote:
Original post by Harry Hunt

<textarea id="myText"></textarea>

<iframe id="myIFrame"></iframe>

<script type="text/javascript">
var myTextElement = document.getElementById("myText");
var myIFrameElement = document.getElementById("myIFrame");

myTextElement.onclick = function() {
myIFrameElement.contentWindow.location.href = "mypage.html";
};
</script>


modified it a bit for my app, it works perfectly thanks :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!