Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Web Node in new window.

Status
Not open for further replies.

Utsav1521

Programmer
Oct 10, 2013
6
IN
Hi Experts,

I have created a webnode and made it promoted, Now I want to open the webnode cmd in new window if it is clicked.
I overreide the link feature to add target="_blank" but it didn't work.
Could any one help me achieve this.

Thanks in advance.

Regards,
Utsav
 
Hi Utsav,

did you create your own webnode. if so then you can get it to work.

you were looking in the righr direction but on the wrong location for the link construction..

The _ConvertToJSON() method is called when the browse page is constructed. you can find the _ConvertToJSON method inherited by the webnode in oscript. The link construction for the promoted link ( i guess that you want that one to open in a new window) is performed here and defines the attriburtes for the <A>. no option for another attribute ...

below the code from _ConvertToJSON where the promoted link is generated...

.....
// TODO: this should get optimized to not return the full string, but an array that is the href and the name
promotedCmdsStr = ""

for promotedCmd in promotedCmds

/* here it constructs the link */ promotedCmdsStr += Str.Format( '&nbsp;<A HREF="%1" TITLE="%2 %3">%2</A>&nbsp;', promotedCmd.Object.URL( request, nodeRec, nextURL ), promotedCmd.Name, Web.EscapeHTML( nodeRec.Name ) )

end


If your module implements the webnode then override the _ConvertToJSON method for the webnode and add the target="_blank" option.. to the anchot <A>

mind that it loops through all promoted items applicable for the webnode so add some intelligence that not all promoted links open in a new window..

think this does the trick..


 
If you didn't want to change underlying oscript, you could also add JavaScript to a global appearance.
JavaScript:
$( ".promotedCmds" ).each(function( index ) {
	var checkString = ">Open</a>"
	var replaceString = " target='_blank' " + checkString;
	var targetString = $(this).html();
	var check = targetString.indexOf(checkString);
	if(check != -1){
		var result = targetStr.replace(checkStr, rpcStr);
		$( element ).html(result);
	}
});
This looks for the table cell with the .promotedCmds table cell and re-writes the HTML. You would also need to need to take in to account the other Open functions that could be used (function menu, document overview page).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top