Results 1 to 3 of 3

Thread: change to .js file for new window?

  1. #1
    Join Date
    Oct 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question change to .js file for new window?

    1) Script Title: :: AnyLink JS Drop Down Menu v2.3

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...pmenuindex.htm

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

    ========================================================
    Code:
    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
    Last edited by jscheuer1; 03-02-2012 at 07:50 PM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    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:

    Code:
    <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.
    Last edited by jscheuer1; 03-03-2012 at 01:04 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2004
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    works PERFECTLY!

    thanks John...muchly appreciated, eh!

    :-)

    Jim

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •