Adding Javascript to PHP

Post Reply
User avatar
BobW55
Forecaster
Forecaster
Posts: 115
Joined: Thu Sep 28, 2017 11:43 pm
Location: Michigan USA
Station model: Davis Pro2
Software: Cumulus
Contact:

Adding Javascript to PHP

Post by BobW55 » Fri Oct 13, 2017 2:06 pm

My knowledge of WEB Page programming stopped at HTML, and I am very rusty at using that.
I am trying to create my own block to track the International space station (ISS).
I know there is a functioning plug in for this, but I wanted a block.
I am trying to insert this Javascript into a block called isstrack.php
The Javascript is:
<script type="text/javascript" src="http://www.satflare.com/export/xvsft.as ... "></script>

It works fin in HTML, but syntax for PHP eludes me.
I think I am missing defining the size of the output from the script, my block shows up, but only as a small band about one character tall.
I have created a few other blocks that work just fine, this one is kicking my butt!

Bob
http://melvinweather.com/template/indexDesktop.php
Davis Vantage Pro2 wired
Solar/UV sensors
Sky Cam
Ham radio K8pos

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: Adding Javascript to PHP

Post by Jachym » Fri Oct 13, 2017 3:29 pm

Make sure you do not put the JS code inside PHP, PHP has to be separate from HTML and JS. The JS and HTML tags must be outside the PHP tags

User avatar
BobW55
Forecaster
Forecaster
Posts: 115
Joined: Thu Sep 28, 2017 11:43 pm
Location: Michigan USA
Station model: Davis Pro2
Software: Cumulus
Contact:

Re: Adding Javascript to PHP

Post by BobW55 » Fri Oct 13, 2017 4:42 pm

Jachym

That is what I also thought.

Will play with it more, may just end up using the plug in, but a block on the home page would have been a better look.
http://melvinweather.com/template/indexDesktop.php
Davis Vantage Pro2 wired
Solar/UV sensors
Sky Cam
Ham radio K8pos

User avatar
BobW55
Forecaster
Forecaster
Posts: 115
Joined: Thu Sep 28, 2017 11:43 pm
Location: Michigan USA
Station model: Davis Pro2
Software: Cumulus
Contact:

Re: Adding Javascript to PHP

Post by BobW55 » Fri Oct 13, 2017 8:27 pm

Think I am having a problem with my Host Server.
If I save this to an html file:

<!DOCTYPE html>
<html>
<body>

</script>
<script type="text/javascript" src="http://www.satflare.com/export/xvsft.as ... "></script>
</body>
</html>
It runs fine from my Chrome browser.

If I upload the file to my Host server, it loads, starts to run then errors out.
File url: http://melvinweather.com/template/homep ... track.html
Have sent an email to my host Server.
http://melvinweather.com/template/indexDesktop.php
Davis Vantage Pro2 wired
Solar/UV sensors
Sky Cam
Ham radio K8pos

Post Reply