Hey,

I wondering how I can make a "popup"-window (think it is done with Ajax) in the same browser-window?

Click on one of the images in the link below for an example of what I mean.

http://www.railbirds.com/pictures/2/

Dani AI

Generated

asked for an in-window “popup” (think AJAX/modal). Several replies pointed to ready-made lightbox-style scripts (, , ). Below is a minimal, modern pattern you can use instead of a third-party library — it degrades gracefully (links still work without JS), is responsive, and includes basic accessibility and close controls.

<!-- thumbnail link keeps href as fallback -->
<a href="images/large1.jpg" class="thumb" data-large="images/large1.jpg">
  <img src="images/thumb1.jpg" alt="Photo caption">
</a>

<!-- modal (hidden by default) -->
<div id="modal" class="modal" role="dialog" aria-hidden="true" aria-label="Image preview">
  <button id="modalClose" class="modal-close" aria-label="Close">Close</button>
  <img id="modalImg" src="" alt="">
</div>

<style>
.modal { display:none; position:fixed; inset:0; background:rgba(0,0,0,.85);
        justify-content:center; align-items:center; z-index:9999; }
.modal.open { display:flex; }
.modal img { max-width:90vw; max-height:90vh; }
body.noscroll { overflow:hidden; }
</style>

<script>
document.addEventListener('click', function(e){
  var t = e.target.closest && e.target.closest('.thumb');
  if (!t) return;
  e.preventDefault();
  var src = t.dataset.large || t.href;
  var m = document.getElementById('modal');
  document.getElementById('modalImg').src = src;
  m.classList.add('open'); m.setAttribute('aria-hidden','false');
  document.body.classList.add('noscroll');
  document.getElementById('modalClose').focus();
});
function close(){ var m=document.getElementById('modal'); m.classList.remove('open');
  m.setAttribute('aria-hidden','true'); document.body.classList.remove('noscroll');
  document.getElementById('modalImg').src=''; }
document.getElementById('modalClose').addEventListener('click', close);
document.addEventListener('keydown', function(e){ if (e.key==='Escape') close(); });
</script>

Notes and quick tips: keep the anchor href as a no-JS fallback; use data- attributes to avoid loading full images until needed; lock body scrolling while the modal is open; add error handling for failed image loads; use event delegation for performance on galleries; consider history.pushState if you need deep-linking. If you prefer turnkey behavior, the earlier replies list ready-made options, but the tiny vanilla approach above avoids extra dependencies and common conflicts.

Recommended Answers

All 4 Replies

Hi,
Have a look at and tell me if that is what you are looking for?

I will be happy to share the knowledge!

The images on the bottom of the outrigger page are the best example.

This is all done using the system that can be found online.

I hope this helps.

KnowMore (Know More Technology)

use greybox. its open source

GreyBox can be used to display websites, images and other content in a beautiful way.

Why use GreyBox:

* It does not conflict with pop-up blockers
* It's only 22 KB!
* It's super easy to setup
* It's super easy to use
* You can easily alter the style as it is controlled through CSS

EXAMPLES on the website

Thanks this post is very useful to me!!!!!!:)

I prefer to use http://highslide.com/. It's way smaller than lightbox, and I haven't run into the conflicts lightbox has had in existing code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.