Put "target=" in URL Link?

I have a script that has a URL passed to it to dynamically create a JavaScript menu.

I can pass a URL such as:

http://www.(some site).com”

But I want to direct it to the “_top” frame in the URL Link. Is this possible??

I looked at the source from a Domino Form with a link and target frame. It look like this:

This Site

So, I tried using:

http://www.(some site).com” target=“_top”

AND

““http://www.(some site).com” target=‘_top’”

But the menu will not build…

In the code, I tried appending " target=‘top’" but it gave me an Unknown Command Exception…

Any ideas would be great!!!

Thanks!

Dan

Subject: Put “target=” in URL Link???

What format are the actual links in your application taking? That is, does the menu script create this:

Text

or this:

window.location = ‘http://www.somewhere.com’;

Subject: Here is the function I think I should update…

function GoTo(){// This is where the link is created…

if(this.LinkTxt){

	status='';

	var HP=Nav4?this.LowLyr:this;

	LowItem(HP);

	var MemVal=eval(WhatMenu+'[0]');

	if(MemVal=="Home"){

	    DcLoc=????????????????

	}

	this.LinkTxt.indexOf('javascript:')!=-1?eval(this.LinkTxt):DcLoc.location.href=this.LinkTxt

}

}

The “DcLoc” variable is the frame…

I check to see if the first occurrence in the array I pass is set to “Home.” Then I create the link…

How would I change it correctly to reflect the “_top” target???

parent.frames[‘_top’]???

parent.frames[‘_new’]???

Since I am using a frame called “BodyFrame” as the target for all links in this menu, for the “Home” link I want to appear correctly - not inside the BodyFrame…

Thanks!

Dan

Subject: Can you “View Source” of a Layer???

Since the JavaScript creates the table dynamically, is there a way to view the sources of that layer???

Subject: RE: Can you “View Source” of a Layer???

That which JavaScript writes in the client is not a part of the source, so “view source” will not help. You can examine the in-memory document to your heart’s content using JavaScript. How’s your DOM-parsing skills?

Subject: DOM skills are shaky at best…

I am not-so-hot with the DOM parsing skills…

First of all, thanks a million Stan for responding and sticking with me on this issue…

I have one more idea/question…

In this .js file that writes the JavaScript, I am trying to pinpoint the place where is creates the actual link statment.

I was thinking if I write a quick function to make sure when it hits the link I want to use “target=‘_top’” on, I can set the target.

The code is from http://www.dynamicdrive.com/dynamicindex1/hvmenu/index.htm

The file I have been working with is the “menu_com.js.”

I am at a loss - any help would be great!!!

Thanks again Stan!

Dan

Subject: RE: DOM skills are shaky at best…

That should be easy enough. You can get a collection of all of the HTML-based links on a document using document.links, then you can look through them individually for some other characteristic:

function setLinkTargets() {

var links = document.links;

for (i=0;i<links.length;i++) {

if (links[i].href) {

if (links[i].href.indexOf(‘http’) {

// if the target cannot be directly set to new

if (!(links[i].target=‘_new’) {

//create a target attribute node for the link

var tartgetNode = document.createAttribute(‘target’);

//set the value of the target

targetNode.value = ‘_new’;

//actually put the attribute in the link

links[i].setAttribute(targetNode);

}

}

}

}

}

Some older browsers will upchuck and die if they come across DOM methods, so we’ll try to set the target attribute directly first. Newer browsers won’t let you set the target unless it already exists as an attribute node, so we’ve got code in the to create and set the target node if necessary.

Subject: Where is optimal place to put this code???

I have a subform which contains the menu code:

Should I place the code in the JSHeader of the subform and call it after the code above???

Or do I place this function in the .js file and call it from the subform???

I changed the “indexOf” to find the link I am looking for.

Question: The “.links” property also looks for those in layers???

Thanks!

Dan

Subject: RE: Where is optimal place to put this code???

Unless otherwise specified, JavaScript belongs in a .js file. As for the .links property, it should grab everything, even in Netscape 4. If I remember correctly, it was one of the few collections that didn’t need to go through a layers hierarchy. Apart from Netscape 4, all browsers let you address collections “flat”; .links contains all links, .images contains all images, and so forth. In up-to-date browsers, you can even use document.getElementsByTagName(‘a’) to get all of the link nodes.

Subject: Some results…

I place the function it in a .js file…

I should call it from the subform after the menu has been built? or from the “onLoad” event on the Form???

I’m guessing I should call from the subform after the menu has been built…

I tried placing the function in the .js file that contains the code to build the menu.

I tried calling this function right after the “function Go()” in the HTML of the subform:

but I get the “Object expected” error.

I tried placing this function in the custom .js file at the end, and tried calling it also. Got the “Object expected” error again.

I am missing something in the call??? Since I am not passing any variables or objects, isn’t the call “setLinkTargets()”???

Thanks again for all your help!

Dan

Subject: Does “document.links” property find links in layers???

I am trying to find all links in a document on the web using the following function from a ND6 forum post that I customized :1. function setLinkTargets() {

  1. alert(“In setLinkTargets…”);

  2. var links = document.links;

  3. alert("In setLinkTargets…links.length: " + links.length);

  4. for (i=0;i<links.length;i++) {

  5. alert(“In setLinkTargets…links[”+ i +"].href: " + links[i].href);

  6. alert(“In setLinkTargets…links[”+ i +"].target: " + links[i].target);

  7. var hrefName = links[i].href;

  8. alert("In setLinkTargets…hrefName: " + hrefName);

  9. if (hrefName != “”) {

  10. if (hrefName.indexOf(‘http//’)) {

  11. alert(“In setLinkTargets…found http…”);

  12. var targetName = links[i].target;

  13. alert("In setLinkTargets…targetName: " + targetName);

  14. // if the target cannot be directly set to new

  15. if (targetName !=‘_new’) {

  16. //create a target attribute node for the link

  17. alert(“In setLinkTargets…not ‘_new’ target…”);

  18. var targetNode = links[i].createAttribute(‘target’);

  19. //set the value of the target

  20. targetNode.value = ‘_new’;

  21. alert(“In setLinkTargets…New links[”+ i +"].href: " + links[i].href);

  22. alert(“In setLinkTargets…New links[”+ i +"].target: " + links[i].target);

  23. }

  24. }

  25. }

  26. }

  27. }

I place this in the JSHeader of the form and call “setLinkTargets()” from the “onLoad” event. I have also placed in a “.js” file loaded in a subform and made the call from the onLoad event of the form.

However, it only finds the links in the document, not in the layer. I tested this by creating a button with the call “setLinkTargets()” - placed some alert statements and saw the links. I am assuming that once the form is loaded all links are loaded, even in the layer(s). I press the button once the form is loaded.

Line 19 throws an “Object doesn’t support this property or method” error.

I know that is a DOM method. I am using IE 6 for testing right now.

So, my questions are:

  1. How do you get the links from a layer?

  2. How do you fix the code in Line 19?

Thanks!

Dan

Subject: RE: Put “target=” in URL Link???

I pass the value to a JavaScript function as:

http://www.mysite.com

Thanks!

Dan

Subject: Put “target=” in URL Link???

HiI have a similar problem. When my url contains target=“_blank” it tries to open it in Notes window itself. The link contains another web application url which is sent to notes through email. If this url is opened in Notes e-mail, it generates error as it is opened in Notes itself.

It works for my friends: The url opens up in Internet Explorer (set as default browser in Notes settings).

Please tell me what settings need to be changed in Notes so that ,my url opens in Web browser?

Waiting for an early response.

I would be thankful

Mehak Kapoor