473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

IE + Iframe popup problem

XP
Hello Everyone,

I was stuck with this really frustrating problem for sometime. Let me
explain what I am trying to achieve: There is a form and an inner
iframe. The form's target is set to the iframe so that when the form
is submitted, the page does not get reloaded/changed ( as the iframe
would be the one getting refreshed. The Iframe is set to have 0 width
and height to make it look invisible ).

I have a copied the html source ( at the end ) to demonstrate this.
There are 2 form/iframe pair
a) Static form / iframe
b) Javascript generated form / iframe.
and both forms are submitted using javascript.

In firefox, both a) and b) works perfectly ( i.e there are no
popups / page reloads/ page change )
In IE, a) works fine BUT b) does not ( a popup is created when the
form is submitted )

I am failing to understand why b) is not working in IE ( i.e why
the popup is appearing ).
Could someone help me on this one ?

Thanks

HTML Code

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Insert title here</title>
<script>
function badTest ( ) {
//document.getElementById ('upload_form_1234').submit();
document.forms['upload_form_1234'].submit();
}

function goodTest ( ) {
document.getElementById ('asd').submit();
}

function tryLoad ( ) {
var newDiv = document.createElement('div');
var newForm = document.createElement('form');
var uniqueId = '1234' ;
newForm.setAttribute('enctype','multipart/form-data') ;
newForm.setAttribute('id','upload_form_' + uniqueId ) ;
newForm.setAttribute('name','upload_form_' + uniqueId ) ;
newForm.setAttribute('method','post' ) ;
newForm.setAttribute('action','index.php/media/upload') ;
newForm.setAttribute('target','form_' + uniqueId + '_iframe') ;

var fileElement = document.createElement('input');
fileElement.setAttribute('type','file') ;
fileElement.setAttribute('id','image_file') ;
fileElement.setAttribute('name','image_file') ;
newForm.appendChild(fileElement);
newDiv.appendChild(newForm);

var iFrameElement = document.createElement('iframe');
iFrameElement.setAttribute('name','form_' + uniqueId +
'_iframe') ;
iFrameElement.setAttribute('id','form_' + uniqueId +
'_iframe') ;
iFrameElement.setAttribute('src','public/html/blank.html') ;
iFrameElement.setAttribute("style","border:0px;hei ght:0px;width:
0px;padding:0px;position:absolute");
iFrameElement.style.border = 0 ;
iFrameElement.style.height = 0 ;
iFrameElement.style.width = 0 ;
iFrameElement.style.padding = 0 ;
iFrameElement.style.position = 'absolute' ;
newDiv.appendChild(iFrameElement);
document.getElementById ('uploadForms').appendChild ( newDiv ) ;
}
</script>
</head>
<body onload="tryLoad()">
<button onclick="goodTest()"Good Test </button>
<form id="asd" enctype="multipart/form-data" method="post"
action="index.php" target="testframe">
<input type="file">
</form>
<iframe name="testframe" id="testframe" src="public/html/blank.html"
style="border:0;height:0;width:0;padding:0;positio n:'absolute' " >
</iframe>
<br/><br/><br/>
<button onclick="badTest()"Bad IE Test </button>
<div id="uploadForms"</div>
</body>
</html>

Apr 18 '07 #1
1 5245
On Apr 18, 8:04 pm, XP <rakes...@gmail.comwrote:
Hello Everyone,

I was stuck with this really frustrating problem for sometime. Let me
explain what I am trying to achieve: There is a form and an inner
iframe. The form's target is set to the iframe so that when the form
is submitted, the page does not get reloaded/changed ( as the iframe
would be the one getting refreshed. The Iframe is set to have 0 width
and height to make it look invisible ).

I have a copied the html source ( at the end ) to demonstrate this.
There are 2 form/iframe pair
a) Static form / iframe
b) Javascript generated form / iframe.
and both forms are submitted using javascript.

In firefox, both a) and b) works perfectly ( i.e there are no
popups / page reloads/ page change )
In IE, a) works fine BUT b) does not ( a popup is created when the
form is submitted )

I am failing to understand why b) is not working in IE ( i.e why
the popup is appearing ).
Could someone help me on this one ?

Thanks

HTML Code

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<title>Insert title here</title>
<script>
function badTest ( ) {
//document.getElementById ('upload_form_1234').submit();
document.forms['upload_form_1234'].submit();
}

function goodTest ( ) {
document.getElementById ('asd').submit();
}

function tryLoad ( ) {
var newDiv = document.createElement('div');
var newForm = document.createElement('form');
var uniqueId = '1234' ;
newForm.setAttribute('enctype','multipart/form-data') ;
newForm.setAttribute('id','upload_form_' + uniqueId ) ;
newForm.setAttribute('name','upload_form_' + uniqueId ) ;
newForm.setAttribute('method','post' ) ;
newForm.setAttribute('action','index.php/media/upload') ;
newForm.setAttribute('target','form_' + uniqueId + '_iframe') ;

var fileElement = document.createElement('input');
fileElement.setAttribute('type','file') ;
fileElement.setAttribute('id','image_file') ;
fileElement.setAttribute('name','image_file') ;
newForm.appendChild(fileElement);
newDiv.appendChild(newForm);

var iFrameElement = document.createElement('iframe');
iFrameElement.setAttribute('name','form_' + uniqueId +
'_iframe') ;
iFrameElement.setAttribute('id','form_' + uniqueId +
'_iframe') ;
iFrameElement.setAttribute('src','public/html/blank.html') ;
iFrameElement.setAttribute("style","border:0px;hei ght:0px;width:
0px;padding:0px;position:absolute");
iFrameElement.style.border = 0 ;
iFrameElement.style.height = 0 ;
iFrameElement.style.width = 0 ;
iFrameElement.style.padding = 0 ;
iFrameElement.style.position = 'absolute' ;
newDiv.appendChild(iFrameElement);
document.getElementById ('uploadForms').appendChild ( newDiv ) ;
}
</script>
</head>
<body onload="tryLoad()">
<button onclick="goodTest()"Good Test </button>
<form id="asd" enctype="multipart/form-data" method="post"
action="index.php" target="testframe">
<input type="file">
</form>
<iframe name="testframe" id="testframe" src="public/html/blank.html"
style="border:0;height:0;width:0;padding:0;positio n:'absolute' " >
</iframe>
<br/><br/><br/>
<button onclick="badTest()"Bad IE Test </button>
<div id="uploadForms"</div>
</body>
</html>
try not using setattribute on the iframe for the name attribute,
instead after it has been created, set the name property the old
fashioned way. using
obj.name='form_' + uniqueId + '_iframe'
format, ie6 has trouble with setattribute.
the "popup" is just the new window created when posting to a window
whose name isnt available yet, once you set it using the name
attribute the old way, it will exist and will be posted to with no
need for a new window. up with firefox and those browsers which make
an effort.

Apr 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Javier | last post by:
Hello, I'm very new in this forum and as I have the following problem, the website is in http://new.vanara.com ----------------------------------------------------------------------------...
2
by: sebastiraj | last post by:
I have one JSP program in which one iframe is defined. And the source of which is an another jsp. Contents of an iframe is in hyperlink. When i click any of the hyperlinks one popup box will come....
1
by: nospam | last post by:
All I am trying to achieve the following: Main window page's asp code writes the following line to launch a popup window (note the IFRAME has to be in the popup window, it cannot be in the...
3
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then...
7
by: ukrbend | last post by:
I use an iframe on my home page and everything works perfectly. But now I decided to add a popups to my page. The popups come not from within the iframe but from the parent frame. Again, everything...
3
by: webEater | last post by:
Hi I have a problem with a piece of javascript. i am working on a workaround for non ajax compatible browser like ie 5/6 without activeX and opera8- I use dynamically created iframes and...
1
by: jadeite100 | last post by:
Hi: I am using IE 6 SP2. My resize attribute does not work <body onresize="test1();">. When I resize my window, the resize event doesnot get call. I have a jsp page with an iFrame called...
1
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to...
1
by: bnashenas1984 | last post by:
Hi everyone I'v seen several websites doing what I'm asking now but I don't know how they do it. Lets say we have an E-commerce website that has a shopping cart inside an IFrame which shows what...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.