open images in a certain area in a popup window Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
2 posters

    open images in a certain area in a popup window

    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved open images in a certain area in a popup window

    Post by _Twisted_Mods_ November 23rd 2014, 11:23 am

    ok so i resized all images inside my #chatbox

    so now what i wanna do is if someone clicks on the img it will open the image in a popup window so they can see it fullsize... and i only ant it to effect the images inside of the #chatbox element


    yes i know more work for for you ange .. and ty for the script cause your probably only one on here who can do it


    Last edited by _Twisted_Mods_ on November 24th 2014, 2:20 am; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur November 23rd 2014, 11:41 am

    Hello _twisted_mods_,

    Something like this ?
    open images in a certain area in a popup window Captur87

    Administration Panel > Modules > JavaScript codes management > Create a new script

    Title : Your choice
    Placement : In the homepage
    Code:
    $(function() {
      var fa_chat = document.getElementById('frame_chatbox'), frame, overlay = document.createElement('DIV'), image = document.createElement('IMG');
      if (!fa_chat) return;
      
      overlay.onclick = function() { this.style.display = 'none' };
      overlay.setAttribute('style','display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.4);z-index:100000;text-align:center;');
      document.body.appendChild(overlay), overlay.appendChild(image);
      
      fa_chat.onload = function() {    
        if (fa_chat.contentDocument) frame = fa_chat.contentDocument;
        else if (fa_chat.contentWindow) frame = fa_chat.contentWindow.document;
        
        
        // kill the interval if archives are enabled
        var a = frame.getElementsByTagName('A');
        for (i=0; i<a.length; i++) if (/archives/.test(a[i].href)) a[i].onclick = function() { window.clearInterval(_chat_refresh) };

        // execute code in an interval
        _chat_refresh = window.setInterval(function() {
          var img = frame.getElementById('chatbox').getElementsByTagName('IMG'),i;
          for (i=0; i<img.length; i++) {
            img[i].onclick = function() {
              overlay.style.display = 'block';
              image.src = this.src;
            }
          }
        },100);
      }
    });
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ November 23rd 2014, 1:42 pm

    work awesome but is there a way to prevent it from reloading the img each times it clicked and it minimized back to the chatbox
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur November 24th 2014, 12:52 am

    Could you explain what you mean ? From what I tried, the image was already loaded.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ November 24th 2014, 12:55 am

    ok lets say i have a img in the chat box and i click it

    when it pops up it reloads the image in the overlay like it was never open

    then when i minimize it back to the chat box the img in the chatbox reloads like it was never open


    if you dont understand me from there ill try to take screenshots or something
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur November 24th 2014, 1:00 am

    That's weird, it doesn't do that for me. Shocked

    Usually when you view an image, the data of that image is cached by its URL : https://2img.net/i/bl/logo.png So, wherever I view that image, it will be loaded already, unless I clear my cache.

    Did you make any changes to how data is saved for your browser ?
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ November 24th 2014, 1:14 am

    no but i use my phones internet and it its tethered to my pc using virtual network and a proxy so maybe thats the issue
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur November 24th 2014, 1:32 am

    It must be, because I tested on IE, Chrome, and Firefox + Aurora. All reacted the same by caching the image.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ November 24th 2014, 2:19 am

    ok then this is

    solved

    as always thankyou for you help once again
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur November 24th 2014, 2:59 am

    Anytime Smile

    Topic archived