Link to home
Start Free TrialLog in
Avatar of magento
magento

asked on

Magento Jquery - url open in new window

Hi,

In my top menu the are no of categories.

I added magento url rewrite for my blog .So when i click the category nccf it will take me to my external blog.

Currently it works fine, but i need them to open in new window instead open in same window

The html code below

<li class="level0 nav-4 level-top">
<a href="http://shop.testdomain.org/auction.html" class="level-top">
<span>Auction</span>
</a>
</li>
<li class="level0 nav-5 last level-top">
<a href="http://shop.testdomain.org/nccf.html" class="level-top">
<span>NCCF</span>
</a>
</li>

Open in new window


I googled for it and find few answers but none works for me when i test using firebug.

Thanks
Avatar of Gary
Gary
Flag of Ireland image

Add target="_blank" into the anchor tag.
Avatar of magento
magento

ASKER

Gary ,

The above html was populated by php script so i cant able to do it for this particular category.

Thanks
How are the links being created? What script?
Avatar of magento

ASKER

I dont know how it was created.

Is it possible to have a jquery when an href is clicked make it open in new window ?

Thanks
Is it just this link?
http://shop.testdomain.org/nccf.html

In your footer somewhere add
<script>
$(function() {
     $('[href="http://shop.testdomain.org/nccf.html"]').prop("target","_blank")
})
</script>

Open in new window

Avatar of magento

ASKER

Modified ur code and then tried the below no luck.

mst( document ).click(function() {
$('[href="http://shop.testdomain.org/nccf.html"]').prop("target","_blank")
});

Open in new window

Why have you changed it - that would fire everytime someone click the page - waste of time and resources.
Is mst your local jquery name?

mst(function() {
     mst('[href="http://shop.testdomain.org/nccf.html"]').prop("target","_blank")
})
Avatar of magento

ASKER

Gary,

What  i have done is , write a rewrite in magento for http://shop.testdomain.org/nccf.html.

When i mouse hover the NCCF link it shows href as http://shop.testdomain.org/nccf.html

But when i click it , it loads in same page and took me to another website url.

I need the same now but in new window.

I will try your code and post back the result tomorrow.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of magento

ASKER

Gary,

The above post worked like a charm .

Thank you very much.

BR,
Magento