Moving Javascript and .js files to a diff server....

Discussion in 'JavaScript' started by Yshua, Jun 10, 2014.

  1. #1
    Dear Digital forum:

    Just read why my headers were missing on https instead of http, because of "mixed content" of JavaScript files and stylesheets in the header which were subsequently blocked. Mozilla web developer advised, you can use protocol relative links:

    <script src="//example.com/script.js" type></script>

    Apparently this means, set up another website with my script code, and other media, for instance, so that all such code is unblocked. Any reservations to this?

    Thanks, dear community,
    Yshua
     
    Yshua, Jun 10, 2014 IP
  2. O-D-T

    O-D-T Member

    Messages:
    180
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    43
    #2
    Hi,

    it does not really mean that you need to set up another website.

    Double slash syntax "//something" will change either to
    https://something
    Code (markup):
    or to
    http://something
    Code (markup):
    depending on the protocol used to obtain the source page.

    This is an example of how Google AdSense scripts can be loaded:
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

    So, if you have a script on your website and a part of your website is accessible via HTTPS, then you can use the // syntax to avoid mixed content problem. What you need to make sure is that the script is accessible using both HTTP and HTTPS.
     
    O-D-T, Jun 10, 2014 IP
  3. Yshua

    Yshua Greenhorn

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Dear O-D-T:

    Thanks to your reply, now have a basket of questions, any one of which being answered might give me a breakthrough!

    Our server is being called through https on virtual host 443, like many others. Although, AT THIS TIME, site can be accessed by http or https. And also, of course, the site will later be accessed EXCLUSIVELY through https! Am hoping this form of .js access you are talking about will still work?! Here is current coding attempt:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html><head><title>Our website</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
    <body><table align="center"><tr><td>
    <table width="843" height="503" align="center" bgcolor="#F7F7F7">
    <tr> <td height="42"><?php include "//index.php/ourwebsite.com/includes/header.php"; /php?></td>
    </tr> <tr> <td height="453" valign="center">
    <table width="799" height="385" align="center"><tr><td height="379" valign="top">

    And the original line changed above was:

    <tr> <td height="42"><?php include "includes/header.php"; /php?></td>.

    My current attempts to implement your procedure have failed. Was unsure what Pagead2 vs. Pagead is equivaltent to.... Could Pagead2 be taken to be index.php?

    Also, the header.php file and others is where headers and trailers are located in the includes directory. It begins,

    <html>
    <head>
    <title>default.vbprj</title>
    <link href="default-files/styles_wp36t.css" type="text/css" rel="stylesheet"/>
    <style type="text/css">A#vbUL_wp36ta{display:none}</style>
    </head>
    <body>
    <table width="835" height="154" bgcolor="#F7F7F7">
    <tr>
    <td width="573" height="104"><a href="index.php"><img src="images/siteheader.bmp" border="0"></a></td>
    <td width="240">&nbsp;</td>
    </tr>

    This should likely need modification too, since it includes .css file, images directory, and stylesheet! Will gladly test it out in its component parts just to get some kind of header back....

    Any answer(s) will help, thank you,
    Yshua
     
    Yshua, Jun 11, 2014 IP
  4. O-D-T

    O-D-T Member

    Messages:
    180
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    43
    #4
    Hi, you make a simple error - that // syntax works only for HTML processed by the browsers, it does not work for PHP code.
    This is why
    <?php include "//index.php/ourwebsite.com/includes/header.php"; /php?>
    makes no sense and will not work as you expect.

    Another weird thing is that you try to insert a file that contains <html> and <head> tag into a code that also contains <html> and <head> tag. Load that page in your browser and check the page source to see the final effect, this is not what you want.
     
    O-D-T, Jun 11, 2014 IP
  5. Yshua

    Yshua Greenhorn

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    Dear O-D-T:

    Could be something different is a larger block...!
    Am only now setting up FTP as well, using Apache-ftpserver. Following error occurred:

    ERROR: JAVA_HOME not found in your environment.
    Please set the JAVA_HOME variable in your environment to match the
    location of your Java installation

    Oops! How is this undertaken?

    Regrouping,
    Yshua:oops:
     
    Yshua, Jun 13, 2014 IP
  6. Yshua

    Yshua Greenhorn

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Dear forum people:

    Must quickly withdraw this question, as am completely aware of a different cause behind the apparent "JavaScript" issue.... Thanks so much, especially to you, O-D-T, for the shared insights.
     
    Yshua, Jun 13, 2014 IP
  7. O-D-T

    O-D-T Member

    Messages:
    180
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    43
    #7
    You're welcome, good luck
     
    O-D-T, Jun 14, 2014 IP