Submitting a form inside an iframe using javascript
I have a link created by the following html/javascript:
<a href=""javascript: var frm=myDoc.forms['f_inv']; frm.action='tek9.asp?pg=inventory&mode=dup'; frm.submit();"">Copy Item</a>
myDoc is: top.frames[0].document;
This is supposed to post the form. It works fine in all browsers when run outside an iframe, but, once I get it inside the iframe, it only works in IE and not in Firefox.
What am I doing wrong?
Ok: A follow-up. I got this to work, but now I'm wondering why I was able to. I set myDoc = top.frames[0].document; further up in the form crea开发者_如何学Ction and then I try to use it in the link declaration. It works fine in IE. But, when I'm in Firefox, I can't use myDoc. I have to explicitly use top.frames[0].document instead. Why is this?
That's probably because of some security issues. I would suggest putting the form inside the root-document and setting form.target to the name of the iframe.
精彩评论