IE Issue: Submitting form to an iframe using javascript -


I was trying to create an iframe element using javascript, such as:

  Var iframe = Document.createElement ('iframe'); Iframe.setAttribute ('name', 'frame_x');  

However, when I try to submit a form using the newly created IFrame as a target, IE opens a new window rather than using an iframe.

form.setAttribute ('target', 'frame_x'); Form.submit ();

It works perfectly in Firefox. In addition, iframe is created but is not used.

You

You set the name attribute of any element in IE by using the standard DOM method .setAttribute ('name', value);

You need to use one of the following:

  // A (any browser) var iframe = document.createElement ('iframe'); Iframe.name = 'frame_x'; //b (in IE only) var iframe = document.createElement ('& lt; iframe name = "frame_x" / & gt;'); // c (use the js library which fixes the bug (like jquery)) iframe = $ ('iframe name = "frame_x">  gt;'); // D (Use jQuery to set the attribute on an existing element) $ ('iframe: first'). Attr ('name', 'frame_x');  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -