473,802 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

set target frame for jumpURL function

Hi all

I have done lots of VB programming, but am not familiar with JavaScript.

Can anyone tell me how to do this ....?

I have a JS file for a menu system called menu.js

It contains the following function :

this.jumpURL = function(url) {
if(url) document.locati on.href = url;
}

I want to get the function to select the 'target' frame / page / etc
depending on variables sent to the function.

eg
this.jumpURL = function(url, target) {
if(url) target.location .href = url;

If I then call the function jumpURL (www.abcd.com, InFrame1 )
it should open the page in an inline frame named InFrame1

For some reason I cannot grasp how to make this work.

However, if I change it to :
if(url) InFrame1.locati on.href = url;
it works fine ( ie.. with the physical name of the frame in the statement ).

SO.......How can I use a variable in place of "InFrame1" ?

or do I need something along the lines of :

if target = "InFrame1" then if(url) InFrame1.locati on.href = url;
if target = "InFrame2" then if(url) InFrame2.locati on.href = url;
if target = "InFrame3" then if(url) InFrame3.locati on.href = url;

This would be the VB style of IF statement - I do not understand the JS
structure yet.

However, this would be very limiting meaning that I would need to modify the
function in the menu.js file every time my html page was changed.

My thanks and appreciation in advance for any assistance.

DaveO

Jul 23 '05 #1
4 13864
In article <d6**********@c tb-nnrp2.saix.net> , js******@mweb.c o.za enlightened
us with...
this.jumpURL = function(url, target) {
if(url) target.location .href = url;


this.jumpURL = function(url, target) {
if (url) {
if (!target) {
// call the default frame "main" or something
target = "main";
}
top.frames[target].document.locat ion.href = url;
}
}

And do note that while vb comparisons and assignments both use the "=" sign,
javascript uses "=" for assignment and "==" for comparisons. A little tip for
you. ;)

--
--
~kaeli~
With her marriage, she got a new name and a dress.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Hi kaeli

Many thanks for the info.

However, is the line target = "main" not assigning a value ( "main" ) to
the variable ( target ) ?
What I want is to have the href statement to use a value 'passed' to the
function in the "this.jumpU RL" line.

We may have up to 6 different InLine Frames ( iFrames ) on our page, and
each menu item passes the URL and target to the jumpURL function.
The target can be any one of the 6 iFrames.

I have hard coded the function for now as follows :

this.jumpURL = function(url, target) {

var targetF = "(Default)" // the default is the BodyFrame iFrame
var targetS = "same" //target is same window
var targetN = "_new" //target is a new window
var NoURL = "(No URL)" //there is no URL for this menu button to link to
var targetBF = "BodyFrame" // this is the name of 1 of the iFrames

if(url == NoURL){
targetF = "_";
targetS = "_";
targetN = "_";
targetBF = "_";
}

if(target == targetF) if(url) BodyFrame.locat ion.href = url;
if(target == targetBF) if(url) BodyFrame.locat ion.href = url;
if(target == targetS) if(url) document.locati on.href = url;
if(target == targetN) window.open(url );
but would prefer to find a way to get it to work with the passes target
value.

Regards

DaveO
---------------------------------------------------
"kaeli" <ti******@NOSPA M.comcast.net> wrote in message
news:MP******** *************** *@nntp.lucent.c om...
In article <d6**********@c tb-nnrp2.saix.net> , js******@mweb.c o.za
enlightened
us with...
this.jumpURL = function(url, target) {
if(url) target.location .href = url;


this.jumpURL = function(url, target) {
if (url) {
if (!target) {
// call the default frame "main" or something
target = "main";
}
top.frames[target].document.locat ion.href = url;
}
}

And do note that while vb comparisons and assignments both use the "=" sign,
javascript uses "=" for assignment and "==" for comparisons. A little tip
for
you. ;)

--
--
~kaeli~
With her marriage, she got a new name and a dress.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
Jul 23 '05 #3
<script>
function jump(url,Target ,I){
// I == n for a Frame
if (I == 'n'){
top.frames[Target].location = "http://"+url
}
// I = y for an iframe
if (I == 'y'){
frames[Target].location.href = "http://"+url
}
// I is left blank for normal target
if (I ==''){
window.open("ht tp://"+url, Target,'');
}
}
</script>
<a href="javascrip t:jump('www.dow nload.com','fre e','n')">Frame</a><br>
<a href="javascrip t:jump('www.www .sue.com','sue' ,'y')">Iframe</a><br>
<a href="javascrip t:jump('www.gho st.com','spook' ,'')">Target</a><br>

--
BootNic Friday, May 20, 2005 12:23 PM

The world is very different now. For man holds in his mortal hands the power to abolish all forms of
human poverty, and all forms of human life.
*John Fitzgerald Kennedy, Inaugural Address*
"DaveO" <js******@mweb. co.za> wrote:
news:d6******** **@ctb-nnrp2.saix.net. ...

Hi kaeli

Many thanks for the info.

However, is the line target = "main" not assigning a value (
"main" ) to the variable ( target ) ?
What I want is to have the href statement to use a value 'passed' to
the function in the "this.jumpU RL" line.

We may have up to 6 different InLine Frames ( iFrames ) on our page,
and each menu item passes the URL and target to the jumpURL function.
The target can be any one of the 6 iFrames.

I have hard coded the function for now as follows :

this.jumpURL = function(url, target) {

var targetF = "(Default)" // the default is the BodyFrame iFrame
var targetS = "same" //target is same window
var targetN = "_new" //target is a new window
var NoURL = "(No URL)" //there is no URL for this menu button to
link to var targetBF = "BodyFrame" // this is the name of 1 of the
iFrames

if(url == NoURL){
targetF = "_";
targetS = "_";
targetN = "_";
targetBF = "_";
}

if(target == targetF) if(url) BodyFrame.locat ion.href = url;
if(target == targetBF) if(url) BodyFrame.locat ion.href = url;
if(target == targetS) if(url) document.locati on.href = url;
if(target == targetN) window.open(url );
but would prefer to find a way to get it to work with the passes
target value.

Regards

DaveO
---------------------------------------------------
"kaeli" <ti******@NOSPA M.comcast.net> wrote in message
news:MP******** *************** *@nntp.lucent.c om...
In article <d6**********@c tb-nnrp2.saix.net> , js******@mweb.c o.za
enlightened
us with...
this.jumpURL = function(url, target) {
if(url) target.location .href = url;


this.jumpURL = function(url, target) {
if (url) {
if (!target) {
// call the default frame "main" or something
target = "main";
}
top.frames[target].document.locat ion.href = url;
}
}

And do note that while vb comparisons and assignments both use the
"=" sign, javascript uses "=" for assignment and "==" for
comparisons. A little tip for
you. ;)

--


Jul 23 '05 #4
Hi All

Many Thanks for the solution.

Your kindness is appreciated greatly.

Regards

DaveO

---------------------------------------------------
"BootNic" <Bo*****@bounce .prodigy.net> wrote in message
news:tb******** *********@newss vr17.news.prodi gy.com...
<script>
function jump(url,Target ,I){
// I == n for a Frame
if (I == 'n'){
top.frames[Target].location = "http://"+url
}
// I = y for an iframe
if (I == 'y'){
frames[Target].location.href = "http://"+url
}
// I is left blank for normal target
if (I ==''){
window.open("ht tp://"+url, Target,'');
}
}
</script>
<a href="javascrip t:jump('www.dow nload.com','fre e','n')">Frame</a><br>
<a href="javascrip t:jump('www.www .sue.com','sue' ,'y')">Iframe</a><br>
<a href="javascrip t:jump('www.gho st.com','spook' ,'')">Target</a><br>

--
BootNic Friday, May 20, 2005 12:23 PM

The world is very different now. For man holds in his mortal hands the power
to abolish all forms of
human poverty, and all forms of human life.
*John Fitzgerald Kennedy, Inaugural Address*
"DaveO" <js******@mweb. co.za> wrote:
news:d6******** **@ctb-nnrp2.saix.net. ...

Hi kaeli

Many thanks for the info.

However, is the line target = "main" not assigning a value (
"main" ) to the variable ( target ) ?
What I want is to have the href statement to use a value 'passed' to
the function in the "this.jumpU RL" line.

We may have up to 6 different InLine Frames ( iFrames ) on our page,
and each menu item passes the URL and target to the jumpURL function.
The target can be any one of the 6 iFrames.

I have hard coded the function for now as follows :

this.jumpURL = function(url, target) {

var targetF = "(Default)" // the default is the BodyFrame iFrame
var targetS = "same" //target is same window
var targetN = "_new" //target is a new window
var NoURL = "(No URL)" //there is no URL for this menu button to
link to var targetBF = "BodyFrame" // this is the name of 1 of the
iFrames

if(url == NoURL){
targetF = "_";
targetS = "_";
targetN = "_";
targetBF = "_";
}

if(target == targetF) if(url) BodyFrame.locat ion.href = url;
if(target == targetBF) if(url) BodyFrame.locat ion.href = url;
if(target == targetS) if(url) document.locati on.href = url;
if(target == targetN) window.open(url );
but would prefer to find a way to get it to work with the passes
target value.

Regards

DaveO
---------------------------------------------------
"kaeli" <ti******@NOSPA M.comcast.net> wrote in message
news:MP******** *************** *@nntp.lucent.c om...
In article <d6**********@c tb-nnrp2.saix.net> , js******@mweb.c o.za
enlightened
us with...
this.jumpURL = function(url, target) {
if(url) target.location .href = url;


this.jumpURL = function(url, target) {
if (url) {
if (!target) {
// call the default frame "main" or something
target = "main";
}
top.frames[target].document.locat ion.href = url;
}
}

And do note that while vb comparisons and assignments both use the
"=" sign, javascript uses "=" for assignment and "==" for
comparisons. A little tip for
you. ;)

--

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3276
by: John | last post by:
HI, I was wondering if it is possible to target a named anchor in a frame when opening a new window with a javascript function? has anyone actualy been able to do this? Thanks in advance for your answer Sean
2
8068
by: Kai Grossjohann | last post by:
The following HTML file invoker.html creates a modal dialog: <html><head> <script language="JavaScript"> function popup() { window.showModalDialog("main.html", null, "dialogHeight:300px;dialogWidth:500px;dialogLeft:100;dialogTop:100s"); } </script> </head><body>
2
5307
by: RWD | last post by:
I am trying to figure out how to change the target frame in my hyperlink on a DHTML menu. The menu is in one frame and the target frame is called "main" The code is below: Thanks in advance RWD <script type='text/javascript'>
5
1506
by: J | last post by:
Hi, I'm using the following code snippet to show popup menus (in a header frame) and target the menu options to another frame. This works fine for a single hard-coded frame (e.g. "2" below, in doClick) but I need to pass in the target frame ID when the user clicks, the reason being that different options will target different frames depending on who the user is. the target frame name is in the target attribute of the link tag, i.e. <a...
0
2561
by: Shadow Lynx | last post by:
When using ASP.NET 2.0's built-in TreeView on a page with <BASE target = "AnythingBut_Self"></BASE> in the HEAD, the expand/collapse buttons fail to function. The reason for this is that the hyperlinks generated for the expand/collapse buttons includes javascript code that will execute in the frame specified in the Base Target rather than the current document. To remedy this, TreeView should render a target="_self" attribute for each...
2
5941
by: PieOPah | last post by:
I have a webpage that uses frames (yes I know, frames - previously been flamed about that, but I do not know anything else to use since I am clueless!!! Been asked to cobble together a site since there is a misconception that I know what I am doing!!!) Anyway, one of the things I have been asked to do is create a button that will allow the user to print the contents of the main window (main frame) without the navigation bar (header...
15
2277
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private) web server, so this is not a cross-site scripting attack. But I would prefer not to taint the target page with any extra logic to do this. (I will if I must.) The calling page has these elements:
4
10122
Dököll
by: Dököll | last post by:
Hey Gang! I thought I had a good idea but then I realized JSF doesn't play that... I am trying to mimick what HTML can do in JSF when using target tags to related to inner HTML pages. In orther to get to a links going smoothly in JSF, on would do: <%@ page contentType="text/html" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.