Kushagra Singh Rajput
Kushagra Singh Rajput

Reputation: 299

open a window on the same page after clicking a link

suppose i click a link. How can i open a window over same page. I don't want a new tab or window.... just clicking a link should open something there only I don't want to use target_bank as it opens in new tab. My window should be something as it appears just above the link. To be more specific if i go to www.talkingtextbook.in and suppose i click any link a window appears over the same page. Please help me how can i do this

would this method help??

window.open("www.youraddress.com","_self")

Upvotes: 0

Views: 6214

Answers (4)

Rahul S
Rahul S

Reputation: 11

Yes We can do like using anchor. For eg: Suppose this is menu link

<a href="#sample1">Menu</a>

and content div is:

<div id="sample1">Content</div>

Like that we can add for another items For pop up to occur need to add like "a" tag onclick and we can use that show/hide using jQuery

Upvotes: 0

Juank
Juank

Reputation: 6196

Use js to open a modal or lightbox plugin and skin the modal/lightbox to be 100% in width and height via css

Based on the page you shared you can set up the modal like this

on your html

...
<body>
    your content <a href="#" id="open-modal-1">open modal 1</a>
    <div class="modal" id="modal-1">
        the modal content
    </div>
</body>
...

On your js

var trigger = document.getElementById('open-modal-1'),
    modal = document.getElementById('modal-1');

trigger.addEventListener('click', function(e){
     if (modal.style.display == 'block'){
          modal.style.display = 'none';
     }else{
          modal.style.display = 'block';
     }
}, true);

on your css

.modal {
  display: none;
  overflow: hidden;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1050;
}

Upvotes: 0

Zohaib Waqar
Zohaib Waqar

Reputation: 1239

Please try this.

window.open("", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

The first parameter in window.open , i left empty. you can specify URl to show that page. or what ever you need.( you form etc).

top -> it specify the position where you want to show new window on same page.

Upvotes: 0

Ashish Singhal
Ashish Singhal

Reputation: 425

Try

onClick="window.location='www.youraddress.com'"

It will Open new url on same windows

Upvotes: 1

Related Questions