PDA

View Full Version : change to .js file for new window?



JVRudnick
03-02-2012, 07:12 PM
1) Script Title: :: AnyLink JS Drop Down Menu v2.3

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

3) Describe problem: works perfectly, but I would like to make a small change so that the link as shown here for example

========================================================

var anylinkmenu1={divclass:'anylinkmenu', inlinestyle:'', linktarget:''}anylinkmenu1.items=[
["Press Release: March 1, 2012", "pdfs/PR-3-1-2012.pdf"],
========================================================

- opens up the corresponding .pdf but in a target="_blank" window....

and I can't figure out how to make a change to the scipt anylinkmenu.js to do that?

:-)

Jim

jscheuer1
03-02-2012, 08:04 PM
var anylinkmenu1={divclass:'anylinkmenu', inlinestyle:'', linktarget:'_blank'}
anylinkmenu1.items=[
["Press Release: March 1, 2012", "pdfs/PR-3-1-2012.pdf"],

However, all items in that menu (anylinkmenu1) will use that target. There's no way internal to the script to specify some links having one target and some having another in a given menu.

If that's a problem, don't use _blank there. Rather put this script on the page:


<script type="text/javascript">
document.onclick = function(e){
e = e || event;
var t = e.target || e.srcElement;
if(t.href && /\.pdf/i.test(t.href)){
t.target = '_blank';
}
return true;
};
</script>

It will open all PDF links in a _blank target.

JVRudnick
03-02-2012, 09:20 PM
works PERFECTLY!

thanks John...muchly appreciated, eh!

:-)

Jim