473,222 Members | 1,691 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,222 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 5231
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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.