开发者

get Javascript to not appear as code on the page

I don't know much about this, just having recently started with JavaScript, so simple language would be g开发者_开发百科reatly appreciated.

Whenever I insert JavaScript on a page, it appears in the preview as text on the page and when I update my site it also appears this way. How would I fix this?

Thank you in advance.


There are two ways to inject JavaScript into a page.

Inline in either the head or body of your html page.

<script type="text/javascript">
    alert('this is inline javascript');
</script>

Or you can link to an external JavaScript file from the head of your html document.

<script type="text/javascript" src="path/to/script.js"></script>

Just remember: if the javascript is an external file, save it with the .js extension.


Do you have it within <script type="text/javascript"></script> tags?


You need to provide a sample of what you are doing for us to help you.

However, you might check that your script declaration looks something like this:

<script type="text/javascript">
<!-- //html comment hides script from really old browsers

  myVar = resultsFromAMethod();

//-->
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜