I’m making my own toolbar for my website and would like to create a .JS file so other users and use this toolbar on their sites too. How can I do this ?
Thanks for reading ![]()
I’m making my own toolbar for my website and would like to create a .JS file so other users and use this toolbar on their sites too. How can I do this ?
Thanks for reading ![]()
Simply create a file called something like myplugin.js and write your javascript code in it. Once you have done that its as simply as calling it in the HTML <head> tags
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="myplugin.js"></script>
</head>
<body>
HTML here
</body>
</html>
I did like this
document.write('html code');
document.write('html code');
document.write('html code');
document.write('html code');
That seems to work for me now, but is there a way I can use document.write only once instead of every line shift ?
You can place a backslash at the end of a line to continue on to the next line, which effectively escapes the newline character:
document.write('html code \\
html code \\
html code \\
html code');
Although, you may want to consider using some other technique than document.write
hmm, what kind of technique would that be, any examples to a JS newbie ![]()
That depends on what you’re wanting to output, and where.
Would this be valid for a new JS developer?
document.getElementByID(‘elementID’).innerHTML
Its how i started out basically.