How to work with Javascript inside Web Module

Discussion in 'Frequently Asked Questions' started by BadaBing, Jul 7, 2018.

  1. BadaBing

    BadaBing New Member

    Joined:
    Jul 7, 2018
    Messages:
    1
    Likes Received:
    0
    Hey, first off let me say: THANK YOU SO MUCH FOR THE OPPORTUNITY TO CREATE MY OWN APP, 100% FREE! YOU GUYS ROCK!

    Alright, so basically, what I am trying to do is create an app that opens a bunch of websites in new tabs. I have the JavaScript code, which is


    window.open('https://www.websitehere.com', '_blank');

    window.open('https://www.newwebsitetabhere.com', '_blank');

    So, what I do is I go create a new web module. After that, I click the "web" tab, at the top. Then, I select "web content" and click "source".

    I'm familiar with basic web design, so I know that the JavaScript code MUST go inside the <head> tag.

    The problem is that, once I create a source page that looks exactly like this:

    <html>
    <head>
    <title>Bada Bing!</title>
    window.open('https://www.bing.com/search?q=news&...8-3&sk=&cvid=E5C2CC7DEB6F41C59D8C719E99CB3B01', '_blank');
    window.open('https://www.bing.com/search?q=us ne...8-7&sk=&cvid=3F94DC903289409C8E469D10BCD73FCF', '_blank');
    </head>
    <body>
    Searching...
    </body>
    </html>

    It ends up displaying as this source code, after I publish it:

    <html>
    <head>
    <title>Bada Bing!</title>
    <style type="text/css">
    </style>
    <style type="text/css">
    </style>
    <style type="text/css">
    </style>
    <style type="text/css">
    </style>
    </head>
    <body>&nbsp;</body>
    </html>
    <title></title>
    <p>window.open(&#39;https://www.bing.com/search?q=news&...mp;cvid=E5C2CC7DEB6F41C59D8C719E99CB3B01&#39;, &#39;_blank&#39;); window.open(&#39;https://www.bing.com/search?q=us ne...mp;cvid=3F94DC903289409C8E469D10BCD73FCF&#39;, &#39;_blank&#39;);</p>
    <p>Searching...</p>


    Why does my code, that I put inside the header, end up being spit out and put inside the body? Not only that, but why is my code inactive? I'm pretty sure the code, even if put inside the body, should be ACTIVE.


    Now, I will admit, I am very new with JavaScript. So if there is a format I'm missing, or something, please let me know. I'm thinking maybe I just can't input the code I did alone, like...maybe there is some sort of bigger code needed. For example, you can't just put some html code inside of notepad and name it yourcode.html and expect it to work. What you need is the proper tags of an html page, <html><body> ETC.

    Thank you guys all for reading. Let's hope we can find a solution!
     
    #1

Share This Page