Web Analytics Made Easy -
StatCounter How to create a Link Editor with Javascript? - CodingForum


No announcement yet.

How to create a Link Editor with Javascript?

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create a Link Editor with Javascript?

    I want to create a tool that will add a prefix to link.

    Actually I want to create a Text-box in which a link will be pasted and after pasting when I click Go Button the tool should add some prefix to the pasted link and then redirect browser to the new link (i.e. Pasted Link+Prefix Added) .

    I somehow managed to write some code that will add prefix to the link pasted in the textbox. But i am unable to make the browser redirect to the new prefixed link.

    I tried using " window.location.replace() " for the redirect but its not the solution. Please help me.

    <script language="javascript" type="text/javascript">
    function addtext() {
    	var newtext = "SOME-PREFIX";
    	document.myform.outputtext.value += newtext;
    <form name="myform">
    <td><textarea name="outputtext" rows="6" column="3"></textarea></td><br>
    <input type="button" value="GO" onClick="addtext();"></p>

  • #2
    language="javascript" was last used with Netscape 4 (or was it removed before then - so long ago I forget).
    type="text/javascript" was declared to be obsolete at about the same time and replaced with "application/javascript" - except you still need ed to use the obsolete one for JScript. It became unneeded in HTML 5 where the value gets set on the server instead.

    About 10 years ago it was realised that JavaScript can be much simpler and be run sooner if it is placed just before the </body> tag instead of in the head.

    Your HTML is invalid - <tr> tags must be inside a <thead>, <tbody> or <tfoot> that is inside a <table> with no other tags in between

    Don't jumble JavaScript inside the HTML tags - Netscape 4 was the last browser to need that - now all JavaScript goes in the JavaScript file.

    That document.myform.outputtext.value is a Netscape 2 way of reading info from a form into JavaScript. Now we have getElementById(), getElementByName(), getElementByTagName(), getElementByClassName(), quesrySelector() and querySelectorAll() for referencing the HTML from JavaScript.
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.