...

View Full Version : [Sovled]link targeting iframe opens new window in IE6+7



cblanquera
03-12-2009, 01:39 AM
The solution:
Found my own answer.
var frame = document.createElement('div');
frame.innerHTML = '<iframe id="frame_1" name="frame_1" src="/assets/blank.html"></iframe>';

This frame registers fine in IE6+7


For reference....

The problem:

Hello!

Here's my problem. I have a JavaScript produced iframe on a page. When I click a link targeting that iframe in IE6+7 It opens a new window. The expected functionality is to load the link page in the iframe.

Here's the JavaScript:

//create iframe
var frame = document.createElement('iframe'); //create the iframe
frame.setAttribute('id', 'frame_2'); //set id
frame.setAttribute('name', 'frame_2'); //set name
document.body.appendChild(frame); //append to body

//create link
var a = document.createElement('a'); //create the link
a.setAttribute('href', '/assets/blank.html'); //set href
a.setAttribute('target', 'frame_2'); //set target
a.innerHTML = 'Click this in IE6 or IE7'; //set message
document.body.appendChild(a); //append to body

Here's the implementation: http://js.openovate.com/assets/iframe.html

Any help or corrections would be appreciated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum