Sign in to follow this  
agm_ultimatex

[web] javascript - simple problem (i think)

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this