SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making a link work when JavaScript is Disabled or not available.

    Hello everyone,

    I am using ColorBox to display inline content.
    When the user click a link, a box popup on the screen.

    Here's the problem, when I disable JavaScript, the link does not work.

    Is there anyway to make this work, even when JavaScript is not available?

    The window does not work when JavaScript is not enabled and it shouldn't, but I would still like the link to work.

    Here is the link code:
    Code:
    <a href="https://www.sitepoint.com" onclick="javascript: parent.
    $.fn.colorbox.close(); window.open(this.href); return false;" target="_blank">Continue to Application</a>

    This portion was added because when you click the link in the window, the popup window stayed open even when use use the browser back button. Adding the below code prevents this.
    Code:
    onclick="javascript: parent.
    $.fn.colorbox.close(); window.open(this.href); return false;"
    Any general ideas?

  2. #2
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't make something use JavaScript if JS is disabled. So how can the users get to this link if JS is what makes the link appear? What exactly are you trying to do?? Can we have a link to your example??

  3. #3
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    this
    Code:
    onclick="javascript: parent.
    $.fn.colorbox.close(); window.open(this.href); return false;"
    tells the browser NOT to perform the default action of opening the url you have listed (so that only the Javascript part works).

    Your example shows the SitePoint URL. Do you have a real URL? Because if the link did not work without Javascript then I'm wondering what the return false was doing in there in the first place.

    In other words, the return false suggests to me that the link *should* have been working when Javascript is disabled. What is happening when you click it?

  4. #4
    SitePoint Addict
    Join Date
    Aug 2008
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    this
    Code:
    onclick="javascript: parent.
    $.fn.colorbox.close(); window.open(this.href); return false;"
    tells the browser NOT to perform the default action of opening the url you have listed (so that only the Javascript part works).

    Your example shows the SitePoint URL. Do you have a real URL? Because if the link did not work without Javascript then I'm wondering what the return false was doing in there in the first place.

    In other words, the return false suggests to me that the link *should* have been working when Javascript is disabled. What is happening when you click it?
    Hello Stomme,

    The use of the sitepoint URL is simply for example.

    Here is why this portion -
    Code:
    onclick="javascript: parent.
    $.fn.colorbox.close(); window.open(this.href); return false;"
    was added.

    I am using Colobox which is based on JavaScript (JQuery).

    When you click a link, a window popup like a Modal Dialog box containing inline contents.

    The problem is when the box pop up, there is a link in the box, which the user is suppose to click. However, when the user click the link the colorbox is still open or active on the screen and does not close or go away.

    So adding the above code to the link closes the box when the link is clicked.
    Otherwise the box remain open, even when clicking the link takes you to another page or tab, or when you hit the back button on the browser, the box is still open.

    I can whip up an example but I was hoping this would be a simple fix.

    My apologies!


    IC

  5. #5
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I would understand it better if you made a small example, but...

    The problem is when the box pop up, there is a link in the box,
    As I understand it, Javascript written on one window generally doesn't affect another window... that other window could have it's own JS which closes itself after the link is clicked.
    So, I had been under the impression that the link on the original window was who's not working.

    So yeah, I'd like to see a small demo so I can see what its doing. While I do little with jQuery, I could still probably see how this could work with and without JS.

    Also, maybe this thread should go over to Javascript, where the JS gurus will see this.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •