View Full Version : Iframe

11-15-2010, 08:08 PM

Am new to javascript. I have a requirement where user clicks on a image which should direct to iframe. Please follow 2 scripts and please advice how to open iframe link instead of link in window.open

Image code:

<img src = "../samples/images/Edit3.png" alt = "Edit Status" height = 13 width = 13 onclick = "window.open('../cgi-bin/cognos.cgi?b_action=cognosViewer&ui.action=run&ui.object=%2fcontent%2ffolder%5b%40name%3d%27NARM%27%5d%2fpackage%5b%40name%3d%27TM1_NARM_RISK_DASHB OARD_CREDIT_FINANCE%27%5d%2ffolder%5b%40name%3d%27Credit%20Finance%20Overlay%20Reports%27%5d%2frepor t%5b%40name%3d%27%23%2060%2b%20Rate%27%5d&ui.name=%23%2060%2b%20Rate&run.outputFormat=&run.prompt=true','KPIDetail','width=600,height=350,scrollbars=yes,left=300,top=300')">

Iframe code:

src="http://tm1lab.us.hsbc/TM1Web/TM1WebMain.aspx?AdminHost=tm1lab.us.hsbc&TM1Server=narm_risk_dashboard&action=OpenObject&type=Websheet&value=Applications/CF_Commentary/H60Rate" width="100%" height = "100%" scrolling=no >

Old Pedant
11-15-2010, 09:42 PM
The easy way:

<a target="MyIframeName" href="...put any URL you like in here..." style="text-decoration: none;">
<img src="../samples/images/Edit3.png" alt = "Edit Status" />
<iframe name="MyIframeName" ...></iframe>

When you give a target in an <a> link, if the target is the *NAME* of an <iframe>, then it automatically does what you want.

No JavaScript needed or wanted. Why work harder than that?