aspose 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 84
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: 56221
    
  13

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

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
alsoumahi alBatal
Ranch Hand

Joined: Nov 22, 2009
Posts: 84
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: 56221
    
  13

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: 84
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: 56221
    
  13

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to change url of iframe in javascript
 
Similar Threads
Center a iframe
Clearing History
how to hide and show iframe withen form ?
How to navigate through a web page displayed in iframe ?
URL in a IFRAME