开发者

linking from OnClick to iframe

开发者 https://www.devze.com 2023-02-27 08:02 出处:网络
I am attempting to have a link load an article from my domain in to an iframe. I understand that it is usually easy to link using:

I am attempting to have a link load an article from my domain in to an iframe. I understand that it is usually easy to link using:

<a href="#" onClick="window.open('http://www.google.com');return false">Google</a>

But when it comes to Iframes I am having difficulty formatting the code correctly so that it will display inside the iframe.

I can not use:

<a href="http://www.google.com" target="your_frame_name">Google</a>

Because I开发者_StackOverflow中文版 need to use an onClick so I can execute more than one command.

I have tried iterations of:

<A HREF="#" onclick="window.framename.location='page.htm';">text</A>

<A HREF="#" onClick="window.open('your url', 'frameName'); return false">text</a>

<A HREF="#" onclick="document.framename.location.href='page.htm'; return false">text</a>

and none of them are doing anything.

Thank you in advance,

Spence


use link and do what ever you want to do in onclick event

<a href="http://www.google.com" target="your_frame_name" onclick="executeOnClick()">Google</a>

<script type="text/javascript">
function executeOnClick(){

// add your logic here


return true;
}
</script> 
0

精彩评论

暂无评论...
验证码 换一张
取 消