Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-04-2013, 04:03 PM   PM User | #1
Mattlav
New to the CF scene

 
Join Date: Jul 2012
Location: United Kingdom
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Mattlav is an unknown quantity at this point
How to set part of iframe src dynamically?

Hi all,

i am calling a url via an iframe which is a jre application.. in the url the is parts which im trying to make dynamic so i can set them via a javascript file?

Is this possible so as an example i have:

Code:
<iframe src="http://myname/test/frmservlet?config=test&FORM=FORMNUMBER.fmx&userid=USERNAME/USERNAME@DATABASE" width="100%" height="100%"></iframe>
Of which im trying to me "FORMNUMBER, USERNAME and database" all dynamic bits of the src as they may be different..

can anyone help me?

Matt
Mattlav is offline   Reply With Quote
Old 02-04-2013, 10:26 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,244
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Code:
<html>
...
<body>
...
<iframe id="zamboni" style="width: 100%; height: 100%;"></iframe>
...
<script type="text/javascript">
var formnumber = 7731; // or wherever you get this from
var username = "Harry Houdini";
var database = "topSecret.mdb";

// make sure the values can be used in a URL:
var encFormnumber = encodeURIComponent( formnumber + ".fmx" );
var encUserid = encodeURIComponent( username + "/" + username + "@" + database );

var frm = document.getElementById("zamboni");
frm.src = "http://myname/test/frmservlet?config=test&FORM=" + encFormnumber
        + "&userid=" + encUserid;
</script>
</body>
</html>
Yes, put the JS just before the </body> and after the <iframe>.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

Last edited by Old Pedant; 02-04-2013 at 10:28 PM..
Old Pedant is online now   Reply With Quote
Users who have thanked Old Pedant for this post:
Mattlav (02-04-2013)
Old 02-05-2013, 10:48 AM   PM User | #3
Mattlav
New to the CF scene

 
Join Date: Jul 2012
Location: United Kingdom
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Mattlav is an unknown quantity at this point
Smile

Quote:
Originally Posted by Old Pedant View Post
Code:
<html>
...
<body>
...
<iframe id="zamboni" style="width: 100%; height: 100%;"></iframe>
...
<script type="text/javascript">
var formnumber = 7731; // or wherever you get this from
var username = "Harry Houdini";
var database = "topSecret.mdb";

// make sure the values can be used in a URL:
var encFormnumber = encodeURIComponent( formnumber + ".fmx" );
var encUserid = encodeURIComponent( username + "/" + username + "@" + database );

var frm = document.getElementById("zamboni");
frm.src = "http://myname/test/frmservlet?config=test&FORM=" + encFormnumber
        + "&userid=" + encUserid;
</script>
</body>
</html>
Yes, put the JS just before the </body> and after the <iframe>.
thanks so much.. it worked my brain was having a confused moment!
Mattlav is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:05 PM.


Advertisement
Log in to turn off these ads.