-4

hi am trying to create an external link for a java script program i created and i tried using https://www.000webhost.com but they blocked me, so pleases is there any better way i can do this, plus am still a learner in programming,

here is the code i created and i want it to be linked,

document.body.appendChild(document.createElement('script')).src='https://usscript1.000webhostapp.com/example1';
  • 4
    What exactly are you trying to do? Is your script really hosted at that URL? Why not just type in a plain ` – Pointy Jun 15 '18 at 13:29
  • yea, it was once hosted at the address before but ther band me from the site, so i need another site to host the script then input the – Phyzy Programmer Jun 15 '18 at 13:46
  • 4
    Why don't you put your script on the same site which your page is hosted? – EhsanT Jun 15 '18 at 13:48
  • because of safty and hacker, so am taking it far away than just this, i want this to work first – Phyzy Programmer Jun 15 '18 at 14:31
  • You can just use – goediaz Jun 15 '18 at 16:02

1 Answers1

0

EDIT: For hosting the JS source file on some external server for testing you can use sites like http://yourjavascript.com You can search for more alternatives on Google but this one worked well for me :)

Original Answer: As others pointed out in comments, you can simply put the source url of JavaScript program in src attribute of <script> tag...

<html>
    <head>
        <script src="https://usscript1.000webhostapp.com/example1.js"></script>
    </head>
    <body>...your website's body here...</body>
</html>

Regarding the blocking issue, make sure your src link to the JavaScript file is correct (by opening the link in seperate browser tab or have look at the console in inspect page window for any errors).

You can put the script on the same site and link to it as,

<html>
    <head>
        <script src="/example1.js"></script>
    </head>
    <body>...your website's body here...</body>
</html>

If you are facing issues with putting the file on your site, you can directly put the code of JavaScript program inside <script> tag like this...

<html>
    <head>
        <script>
            ...your JS program goes here...
        </script>
    </head>
    <body>...your website's body here...</body>
</html>
dedman
  • 868
  • 6
  • 16
  • okay, thank you all for anwsering my question, But all am saying is, is there a site that i can past the javascript before actually linking it back to my site? – Phyzy Programmer Jun 15 '18 at 20:30