File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes how to change url of iframe in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to change url of iframe in javascript" Watch "how to change url of iframe in javascript" New topic
Author

how to change url of iframe in javascript

alsoumahi alBatal
Ranch Hand

Joined: Nov 22, 2009
Posts: 94
Hi experts , I am just having a problem that I couldn't change the url of iframe in function of java script , how I could that ??
I have tried other ways but got errors !!! . the iframe is in parent page inside form, based on user action such as click button I want to change the url of iframe so other
pages should appear instead of the one was before .

I have tried this couldn't do it , please help me

I have tried this:


var form = document.forms[0];
var iframeElement = form.elements["Iframe1"];
iframeElement.location.href= "/QC/alertWebForJoint.jsp"

I have tried this:

var iframeElement = document.getElementById('Iframe1');
iframeElement.location.href= "/QC/alertWebForJoint.jsp";

I have tried this:


var iframeElement = parent.document.getElementById('Iframe1');
iframeElement.style.src="/QC/alertWebForJoint.jsp";


what shall I do to change url of iframe , although iframe is inside form??

thaaaaaaaaaanks a lot guys in advance

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

iframeElement.style.src="/QC/alertWebForJoint.jsp";

Why on earth would you expect the src property to be inside the style property?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
alsoumahi alBatal
Ranch Hand

Joined: Nov 22, 2009
Posts: 94
Bear Bibeault wrote:
iframeElement.style.src="/QC/alertWebForJoint.jsp";

Why on earth would you expect the src property to be inside the style property?


becuase I saw one example show me that for the hight not src , I said just to try !!!

please help me how to solve this
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Trying random things is never likely to work.

Get yourself a good reference and actually look up the properties of an iframe and stop randomly guessing.
alsoumahi alBatal
Ranch Hand

Joined: Nov 22, 2009
Posts: 94
Bear Bibeault wrote:Trying random things is never likely to work.

Get yourself a good reference and actually look up the properties of an iframe and stop randomly guessing.


thanks bro , but I have tried at least , do you know what to do now , I need a solution.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

I am not your bro. I am not your lackey. And I am not your substitute for a reference.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to change url of iframe in javascript