This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to change url of iframe in javascript

 
alsoumahi alBatal
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iframeElement.style.src="/QC/alertWebForJoint.jsp";

Why on earth would you expect the src property to be inside the style property?
 
alsoumahi alBatal
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not your bro. I am not your lackey. And I am not your substitute for a reference.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic