0

So actually i am not much familiar with javascript that's why i am going to post it to know something that i am going to know,

So here it is,

Suppose i have html page and hosted on some where on internet and its coding is,

<html>
<head>
<title>Title of the document</title>
</head>

<body>
The content of the document......</p>
The <a href="http://sitelink.com">link</a> of the document ......
</body>

</html> 

In this code Link anchor text use for hyperlink, I would like to use javascript that call from another site, where the link exist and it display over there like this.

<script type="text/javascript" src="http://mysite.com/java.js">  

I want to know that what code i put on java.js so it show the hyperlink in my html file and how and where do i add code to html page and in javascript

Advance Thanks for help :)

7
  • if you are trying to load other links in your site without leaving the page, then you looking for AJAX loading Commented Aug 12, 2013 at 3:19
  • @MichaelB would you like to tell me how to do that, i need complete coding for that, thankyou Commented Aug 12, 2013 at 3:25
  • Try this dzone.com/snippets/converting-links-ajax-links Commented Aug 12, 2013 at 3:33
  • Well in this link there is only 1 code which is added to html but not display the code of javascript ....? Commented Aug 12, 2013 at 3:38
  • I don't get what your trying to do? Commented Aug 12, 2013 at 3:57

2 Answers 2

1

Apologies in advance if I misunderstood your question, but it sounds like you'd like to use JavaScript from another location on your site.

Using the example above, here's what that would look like:

<html>
    <head>
        <title>Title of the document</title>
    </head>

    <body>
        The content of the document......</p>
        The <a href="http://sitelink.com">link</a> of the document ......

        <script type="text/javascript" src="http://mysite.com/java.js"></script>
    </body>

</html> 

You could also link to it in the <head> instead, but it's better for performance if the scripts are placed in the footer.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you but the ahref tag that used in the html code i want this in javascript that called from external, what code i put in java.js ???????
Sorry Amir, but I don't think I understand what it is you're asking.
0

your anchor: href="javascript:linksomething()" and js: function linksomething(){ window.location.href=url; } is this what you want?

1 Comment

No, Its very simple i want to call a link from 3rd party to html page that's it ........ and for that i need both codes on 3rd party code and html code ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.