Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8634091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:38:05+00:00 2026-06-12T09:38:05+00:00

To ensure that my site is friendly to non-javascript users, I’ve built it without

  • 0

To ensure that my site is friendly to non-javascript users, I’ve built it without using JavaScript, and added it once the site was built.

So now I have a link as following:

<a href="http://example.com/panel" id="showPanel">Expand</a>

But if JavaScript is enabled, I use the following code:

$("#showPanel").attr("href", "#showPanel");

to make the link point to #showPanel instead of http://example.com/panel

While this all works fine, I can’t help but wonder if there’s a better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:38:06+00:00Added an answer on June 12, 2026 at 9:38 am

    Load JS files at the bottom of the page. If the JavaScript you are running is once the page has already loaded, then there shouldn’t be an issue.

    $(document).ready(function() {
        // change links.
    });
    

    If you are trying to reduce the raw number of lines of JS, you could try to follow some convention and automate the changing of the URLs:

    var changeAllLinks = function () {
        var allLinks = $("a[href^='http://example.com']");
        for (int i = 0; i < allLinks.length; i++) {
            allLinks[i].attr("href", "#show" + /* substring for the path */);
        }
    };
    

    Just an idea, as something like that (conceptually) may work. You could follow a convention where all links without JS are in the form <a href="http://example.com/foo"> and the change them with JS to <a href="#showFoo">. That way you could loop through all the links and substring to get the path, capitalize the first letter, prepend a #show to the front, and pop it into the href attribute like you are doing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form on my site that lets users direct a message at
I have a table that stores comments users make about images on the site.
A client wants to ensure that I cannot read sensitive data from their site,
I want to ensure that a WCF-ServiceClient State will be closed after using the
I have a rails app which requires users to verify that they own a
I'd like to ensure that certain URLs on my site are always accessed via
Hi I have a Joomla site with a template that has 2 columns. One
I have a site that serves up a pretty substantial Silverlight RIA and it
We are launching a new web site using a sub-domain and need to ensure
Say, if I write a web site using ASP.NET that uses the SQL Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.