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

  • Home
  • SEARCH
  • 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 5963901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:20:09+00:00 2026-05-22T19:20:09+00:00

I have an asp website and am trying to automatically generate some javascript. I

  • 0

I have an asp website and am trying to automatically generate some javascript. I have an ashx file that generates the javascript and then I would like to like to this javascript in a href.
I have seen it done on other websites but can’t work out how its done.

The ashx file called ‘Hello.ashx’ outputs something like

alert("Hello World");

I am trying to execute this as below

<a href="Hello.ashx">Text</a>

How is this done? Is is actually possible or are other websites using some trick?

Your help is greatly appreciated

  • 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-05-22T19:20:10+00:00Added an answer on May 22, 2026 at 7:20 pm

    You want to load the javascript file when the anchor is clicked:

    function loadjs() {
        var head = document.getElementsByTagName('head');
        var s = document.createElement('script');
        s.setAttribute('type', 'text/javascript');
        s.setAttribute('src', 'Hello.ashx');
        head[0].appendChild(s);
        return false;
    }
    
    <a href="javascript: loadjs()">Text</a>
    

    If you’re using jQuery a better approach is:

    <a href="Hello.ashx" id="hello">Text</a>
    
    $(function(){ $('#hello').click(loadjs); });
    

    To load it once:

    var _myscript = null;
    function loadjs() {
        if (_myscript != null) return false;
        _myscript = document.createElement('script');
        //...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET website (in C#) that takes in user data and then
I'm trying to ensure that visitors of my ASP.NET MVC website always have the
I have an ASP.NET application that's trying to copy a file to a remote
I have a ASP.NET website that references another project with contains as resx file.
We currently have an asp.net website that we use to generate html emails. Basically
I have recently inherited a website written in Classic ASP, and am currently trying
I have a ASP.Net website that is failing on AJAX postbacks (both with ASP.Net
I have an ASP.NET website and when I press F5 it automatically attaches to
I have an asp.net website that allows the user to download largish files -
I have an asp.net website that uses forms authentication. There are a few things

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.