#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Yangon, Myanmar
    Posts
    27
    Rep Power
    0

    One function to either close OR go back depending on the window


    I'm using an application on my home server (PHP / MySQL) where the developer decided to use one javascript function for "back" and "close" links to perform back if in a normal window and close if in a popup window.

    Code:
    function goBack(deep) {
    	if (window.opener)
    	 window.close();
    	else
    	 window.history.go(deep || -1);
    }
    Problem is, I want to run the app in a popup window. If I do, then all of the "back" links close my window, except when the app opens another popup and then the "close" links do, in fact, close the window.

    The dev has said that if I can provide code to fix it but "not interfere with current user interface" then he'll implement it.

    I have too little javascript knowledge to know what to do so I'm wondering if someone could either tweak that code above or provide me with code that would work?

    I'm wanting to work in a popup window (non-negotiable) and have any of their "back" links take me back one page, and any "close" links in supplementary popups to close those windows.

    Assume that only the javascript function is all you can tweak, because I'm assuming that changing links or text or other functions throughout their app will not be permitted.

    Here's hoping, and many thanks if you can pull it off.

    Marts
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,124
    Rep Power
    4304
    Welcome back to DevShed, Marts.

    You need some way of differentiating this first popup from any others that it creates.

    Have you considered that popup windows do not work well on smartphones and tablets? These days the use of "lightbox" scripts is much more common.

    However, I'm curious, does anyone around here remember the solution to this issue? (Don't overthink it, it's something that's fairly easy to overlook. Hint: how do you open a popup?)
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Yangon, Myanmar
    Posts
    27
    Rep Power
    0
    Thanks for the welcome back, Kravvitz. I'm amazed you know I've been away for quite a while.

    This app I'm running isn't something I have any control over, except for where to install it, and by the looks of it I don't think smartphones or tablets are on the dev's mind. I'll be running this on a computer for the foreseeable future, and it's just an in-house thing (SOHO) and doesn't need to work for anyone else here running anything except a PC.

IMN logo majestic logo threadwatch logo seochat tools logo