0

how to redirect the cube image to another link after clicking the cube image now in js it redirects to google.com but it opens in another window but i wanted it to display in the same window

<div class="row">
                <div class="span10">
                    <div class="melonhtml5_gallery">
                        **<div onclick="window.open('http://www.google.com', '_blank');" data-caption="Fans" data-image="http://www.defie.co/designerImages/thumbnails/inventory.png"></div>**
                        <div data-caption="Paul Scholes" data-image="http://www.defie.co/designerImages/thumbnails/search.png"></div>
                        <div data-caption="Wayne Rooney" data-image="http://www.defie.co/designerImages/thumbnails/yourFile.png"></div>
                        <div data-caption="Sir Alex Ferguson" data-image="http://www.defie.co/designerImages/thumbnails/shareFiles.png"></div>
                        <div data-caption="Champ" data-image="http://www.defie.co/designerImages/thumbnails/custFile.png"></div>
                        <div data-caption="Group" data-image="http://www.defie.co/designerImages/thumbnails/custQuote.png"></div>
                        <div data-caption="Ryan Giggs" data-image="http://www.defie.co/designerImages/thumbnails/saleOrders.png"></div>
                        <div data-caption="David Beckham" data-image="http://www.defie.co/designerImages/thumbnails/custInvoice.png"></div>
                        <div data-caption="Champ" data-image="http://www.defie.co/designerImages/thumbnails/vendorProfile.png"></div>
                        <div data-caption="Group" data-image="http://www.defie.co/designerImages/thumbnails/vendorQuote.png"></div>
                        <div data-caption="Ryan Giggs" data-image="http://www.defie.co/designerImages/thumbnails/buyOrders.png"></div>
                        <div data-caption="David Beckham" data-image="http://www.defie.co/designerImages/thumbnails/vendorInvoice.png"></div>
                        <div data-caption="Champ" data-image="http://www.defie.co/designerImages/thumbnails/accountsReceivable.png"></div>
                        <div data-caption="Group" data-image="http://www.defie.co/designerImages/thumbnails/customerRMA.png"></div>
                        <div data-caption="Ryan Giggs" data-image="http://www.defie.co/designerImages/thumbnails/production.png"></div>
                        <div data-caption="David Beckham" data-image="http://www.defie.co/designerImages/thumbnails/CRM.png"></div>
                    </div>
                </div>

1 Answer 1

2

Change _blank to _self. This will make the target change from being a new window to the current window

jQuery:

In general I avoid attaching events to a div, and use links or buttons to use click events, but anyway...

$('.melonhtml5_gallery').find('div').click(function(){
  window.open($(this).attr('data-image'), '_self')
  //you can refer to attributes using the following:
  //$(this).attr('data-caption')
})
Sign up to request clarification or add additional context in comments.

6 Comments

thanks for your reply but its not working in the fiddle jsfiddle.net/7pHMy/3
and is it possible to achieve the same functionality in jquery
@user1943618 jsfiddle can perform oddly in certain situations e.g. alert - have you tried testing it outside of a fiddle?
To answer your jquery question, yes it is. I'll update my answer
@AbePetrillo: thanks for your reply but i wanted each div to point to different links.... how to achieve it
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.