• Advertisement
Sign in to follow this  

[web] javascript - simple problem (i think)

This topic is 3644 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