I am running a LAMP server on void linux with an html frontend from my database. For some of the features I want I need to use javascript. I'm fairly new to javascript and have never had to mess with it serverside.
I have attempted to install jQuery and jspdf, I dropped them in the folder I was using for the site /srv/www/apache/incidents and linked them in my html. When jspdf wasn't working I decided to make a test html page which looks like this:
<!DOCTYPE html>
<html>
<head>
<script src="/incidents/jquery-3.4.1.min.js"></script>
</head>
<body>
<p id="demo"></p>
<script>document.getElementByID("demo").innerHTML = "Hello";</script>
</body>
</html>
It should write "Hello" at the top of the page, but it stays blank. Is there something I am doing wrong here or have I missed something in the apache configuration? I searched all the files in /etc/apache/ and searched the repos for anything js/apache related. Nothing shows up in /var/log/httpd/error_log. I know void is a little different, but up until now its been smooth sailing.
your javascript block is wrong
<script>document.getElementByID("demo".innerHTML = "Hello";</script>
there is a missing ) , try like this:
<script>document.getElementById("demo").innerHTML = "Hello";</script>
Related
I got apache running on a blueonyx server. There is a piece of code in a php file which looks like this
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<script type="text/javascript" src="/folder_name1/folder_name2/file_name.nocache.js"></script>
.....
If I load up that page and check the network tab in my browser it loads that file_name.nocache.js fine, I can even go to http://192.168.0.123/folder_name1/folder_name2/file_name.nocache.js and the browser will display the contents of that file.
But if I ssh onto that server, I can't find that file. Not even that folder or any of those folders.
I have checked phpinfo() and it is not auto_prepend_file anything other than a file that just contains putenv("_HTTP_HOST=".#$_SERVER["HTTP_HOST"]);.
I have tried find / -name "folder_name1" with root, no luck either.
I have tried grep on the contents in file_name.nocache.js, no luck either.
I don't understand how is this possible. Can someone shed a light on me please?
To whoever run into similar problem, i found out what happened.
It was these 2 lines here that are pulling the invisible file out of no where:
./etc/httpd/conf/httpd.conf:ProxyPassReverse /folder_name1 http://192.168.0.111/folder_name1
./etc/httpd/conf/httpd.conf:ProxyPass /folder_name1 http://192.168.0.111/folder_name1
I have a simple website with some basic scripts just like this:
<html>
<head>
<title>Welcome to my website but a user can view page source --oops</title>
<script>
//some basic javascript codes i used to build the website
</script>
</head>
<body>
<p>More contents on the actual implementation of the website.<p>
</body>
</html>
Is there a way I can use server side processing technique to cluster the contents of view page source as I have tried using javascript bt no substantial outcome. Please assist!
You can't hide javascript, html, or css from users. You can proccess out in server like php some code but you need to return html. The only way to complicate user's reading of your code, you try minimize javascript/css/html code. YUI compressor can help you:
http://refresh-sf.com
This makes your code more difficult to read, but the behaviour is the same.
Good luck.
I'm working with classic asp on server including the javascript file in the document like this:
<!--#include virtual="datoteke/jsPDF-master/jspdf.js"-->
...when i run my file on server, browser prints all the comments from included files to the screen. I tried to include it also like this:
<script type="text/javascript" src="jsPDF-master/jspdf.js"></script>
...it worked on localhost, but on server it doesn't, i get an error when i create an instance to the class in my javascript file: "[object Error]"
Why is it printing all those comments to the screen and how do I actually include javascript on server side? What did i do wrong?
The browser looks for JavaScript code in <script> tags. Your first statement does not seem to include those tags at all. I guess you want something like this:
<script type="text/javascript">
<!--#include virtual="datoteke/jsPDF-master/jspdf.js"-->
</script>
You should also know that the virtual directive makes a subrequest to load the file through the web server, which I suspect don't need/want. Give file a try.
Edit: There's a quite nice article about SSI in Wikipedia. Please note that IIS supports Server-Side Includes but it isn't related to ASP Classic at all.
I'm tring to understand how to connected my html with another file js, but the issues is with this software call topsytle4 it a trail basic,but for some reason it show the file but no feature can be us that could be use.
Add this line between <head> and </head>:
<script src="your_js_path_here"></script>
I need to render an HTML page server-side and "extract" the raw bytes of a canvas element so I can save it to a PNG. Problem is, the canvas element is created from javascript (I'm using jquery's Flot to generate a chart, basically). So I guess I need a way to "host" the DOM+Javascript functionality from a browser without actually using the browser. I settled on mshtml (but open to any and all suggestions) as it seems that it should be able to to exactly that. This is an ASP.NET MVC project.
I've searched far and wide and haven't seen anything conclusive.
So I have this simple HTML - example kept as simple as possible to demonstrate the problem -
<!DOCTYPE html>
<html>
<head>
<title>Wow</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js" type="text/javascript"></script>
</head>
<body>
<div id="hello">
</div>
<script type="text/javascript">
function simple()
{
$("#hello").append("<p>Hello</p>");
}
</script>
</body>
</html>
which produces the expected output when run from a browser.
I want to be able to load the original HTML into memory, execute the javascript function, then manipulate the final DOM tree. I cannot use any System.Windows.WebBrowser-like class, as my code needs to run in a service environment.
So here's my code:
IHTMLDocument2 domRoot = (IHTMLDocument2)new HTMLDocument();
using (WebClient wc = new WebClient())
{
using (var stream = new StreamReader(wc.OpenRead((string)url)))
{
string html = stream.ReadToEnd();
domRoot.write(html);
domRoot.close();
}
}
while (domRoot.readyState != "complete")
Thread.Sleep(SleepTime);
string beforeScript = domRoot.body.outerHTML;
IHTMLWindow2 parentWin = domRoot.parentWindow;
parentWin.execScript("simple");
while (domRoot.readyState != "complete")
Thread.Sleep(SleepTime);
string afterScript = domRoot.body.outerHTML;
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(domRoot);
domRoot = null;
The problem is, "beforeScript" and "afterScript" are exactly the same. The IHTMLDocument2 instance goes through the normal "uninitialized", "loading", "complete" cycle, no errors are thrown, nothing.
Anybody have any ideas on what I'm doing wrong? Completely lost here.
You can consider using Watin. Generate your page then use Watin api to capture the generated page.
http://fwdnug.com/blogs/ddodgen/archive/2008/06/19/watin-api-capturewebpagetofile.aspx
I found Awesomium Does exactly what I need! "Windowless web-browser framework". Brilliant.
Basically you are trying to do things, which are not intended to be done in that way.
You generate HTML + Javascript to enable the browser to draw it.
You write C# to enable any kind of server side things.
Generating HTML + Javascript on server to load it into a browser on server to be able to save PNG sounds bad.
Did you think about other approaches like generating the image using server side C# component?
Basically, why do you really need to save it on server? Maybe somebody can provide better solution?
See Generating HTML Canvas image data server-side? for a PhantomJs solution (similar to Node.js, but different, single file, no install)