Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-11-02 09:33:38
Point:500 Replies:9 POST_ID:828770USER_ID:11059
Topic:
JavaScript;PHP Scripting Language;Hypertext Markup Language (HTML)
I try to convert my simple setInterval.html html/javascript code into Node.js
for example as follows
setInterval.html
=============================
for example as follows
setInterval.html
=============================
//---[b]setInterval.html[/b] ------Example setInterval classic html/javascipt code for client-side<html><head><script type="text/javascript" >function init(){setInterval(function(){document.write('<a href="http://www.yahoo.com/us" >Click here for Yahoo</a><br>');},2000)}</script></head><body onload="init();"></body></html> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:
setInterval.js for Node.js code
==========================
//-[b]setInterval.js[/b]-----------Example setInterval with Node.js for server-sidevar http = require('http');"http.createServer(function (request, response){ response.setHeader('Content-Type', 'text/html;" charset=UTF-8');" response.writeHead(200);" setInterval(function(){response.write('<"a href="http://www.yahoo.com/us" >"Click here for Yahoo<"/a>"<"br>"');" }, 2000);"}).listen(8124);" 1:2:3:4:5:6:7:8:9:10:11:12:13:
The client-side html code,setInterval.html ,as above is working fine and meet what I expect.
So I also try setInterval.js for Node.js at server that is aslo responding to what I expect
on my browser with http://mysite.com:8124 that is similar output result I did for setInterval.html
But the question is why when I am doing http://mysite.com:8124, the cursor pointer
is always being with looping icon coming out when you point the cursor on blank area of
the browser instance ? I mean the cursor is keeping waiting , why
it is not shown for the case in setInterval.html ?
The cursor is like as
http://www.google.com.hk/imgres?imgurl=http://www.faronics.com/assets/Cursor1.jpg&"imgrefurl=http://www.faronics.com/news/blog/apparently-i%25E2%2580%2599ve-angered-the-internet/&"h=250&"w=250&"sz=12&"tbnid=xryergqK62S4_M:&"tbnh=120&"tbnw=120&"zoom=1&"usg=__CHAhC0pZBrWTwWPHZL1xLA1cbVU=&"docid=BDgnbkhtc-kZ0M&"sa=X&"ei=tCV1UuTiOcaNkgWp3oGwDw&"ved=0CDEQ9QEwAg
And browser instance is also showing looping or waiting icon for setInteval.js case
but not on setInterval.html case
How to make the cursor display look and browser instance look is same in both cases ?
That may be caused by , one is from server-side, other one is at client-side, and
at client-side javascript is running much much faster than server-side node.js so user
can not see the waiting image icon for setInterval.html client-side case. You think so ?
Please advise
Duncan
Author: duncanb7 replied at 2024-11-02 12:46:52
http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js
it might be good article to talk about the advantage.
It seems Node.js platform will help to utilize system resource in more
effiecient. So i think mutil-process tasking is good from Node.js to
save running many tasks in shorter execution time than apache system using CGI/php scripting
appoach.
And coding on Jave-runtime platform server(tomcat) is not easy to write and not exact
compatiable to Javascript code. The idea of java servlet is similar to Node.js on server
Anyway this post , just for my new thought of Node.js and further study.
hava a nice day, talk you later, if have time, just point out what I am wrong in this post
Duncan
it might be good article to talk about the advantage.
It seems Node.js platform will help to utilize system resource in more
effiecient. So i think mutil-process tasking is good from Node.js to
save running many tasks in shorter execution time than apache system using CGI/php scripting
appoach.
And coding on Jave-runtime platform server(tomcat) is not easy to write and not exact
compatiable to Javascript code. The idea of java servlet is similar to Node.js on server
Anyway this post , just for my new thought of Node.js and further study.
hava a nice day, talk you later, if have time, just point out what I am wrong in this post
Duncan
Expert: Dave Baldwin replied at 2024-11-02 12:28:55
I really don't see any advantage to Node.js other than what I mentioned above. All server side languages are 'secure' if no one can break into the server.
And remember that with Node.js, you not only have to write the code for the browser but you also have to write the code that reads the files and delivers it to the browser.
And remember that with Node.js, you not only have to write the code for the browser but you also have to write the code that reads the files and delivers it to the browser.
Author: duncanb7 replied at 2024-11-02 12:21:51
Dear Dave,
Just last question
Do you think Node.js at server-side that will have advantage for
programmer script code security protection , I mean user
could not copy owner's script coding from server.
For example, online Game program on browse could not be easily
to be copied by users that might be other advantage of considering
using Node.js besides those advatnage you mentioned in last post
(But php code is also hidden from user and jquery plugin code is visible to users)
Duncan
Just last question
Do you think Node.js at server-side that will have advantage for
programmer script code security protection , I mean user
could not copy owner's script coding from server.
For example, online Game program on browse could not be easily
to be copied by users that might be other advantage of considering
using Node.js besides those advatnage you mentioned in last post
(But php code is also hidden from user and jquery plugin code is visible to users)
Duncan
Author: duncanb7 replied at 2024-11-02 12:12:53
Thanks for your reply,let me go into detail of Node.js to see
any good features for simplicity
Duncan
any good features for simplicity
Duncan
Accepted Solution
Expert: Dave Baldwin replied at 2024-11-02 11:58:50
500 points GOOD
The main advantages of Node.js are:
Disadvantages are:
For larger web sites, web servers like Apache and IIS are probably going to be faster because they are compiled programs and Node.js is interpreted javascript. I can not think of any reason that Node.js will be faster than other methods. That is especially true of larger projects where it has to perform the same services as both a web server and a server side programming language.
- It can be very simple for simple things.
- You can do it all yourself.
Disadvantages are:
- Web servers like Apache and IIS are much more complete (but are not simple).
- You Have to do it all yourself. Using the libraries that others have written makes it easier.
For larger web sites, web servers like Apache and IIS are probably going to be faster because they are compiled programs and Node.js is interpreted javascript. I can not think of any reason that Node.js will be faster than other methods. That is especially true of larger projects where it has to perform the same services as both a web server and a server side programming language.
Author: duncanb7 replied at 2024-11-02 11:16:21
Yes, it seems I understand a little bit.
Node.js is server process using javascript coding and php is server-side script programming only and client-side javascript code is client-side script programming only.
For mutil-process tasking concern, Node.js will run faster than
other script programming appoach.
Is it what you want to tell me ?
I also send similar thread before
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28283567.html
but it is hard for me to get to know what the advantage of using Node.js is
Node.js is server process using javascript coding and php is server-side script programming only and client-side javascript code is client-side script programming only.
For mutil-process tasking concern, Node.js will run faster than
other script programming appoach.
Is it what you want to tell me ?
I also send similar thread before
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28283567.html
but it is hard for me to get to know what the advantage of using Node.js is
Expert: Dave Baldwin replied at 2024-11-02 11:09:26
The situation is not what you seem to think it is. Node.js has to do the job that PHP and a web server are doing. Even with all the libraries that are available with Node.js, PHP running on a web server like Apache or IIS is a much more mature solution with much more capability. That may be because it has been around a lot longer and a lot more people have worked on it.
And client side javascript can Not do what Node.js does as a server. The situations are just Not the same and you can't really compare them. Node.js runs on the server machine as a server process and has essentially access to everything. Client side javascript is very restricted and has access to very little.
And client side javascript can Not do what Node.js does as a server. The situations are just Not the same and you can't really compare them. Node.js runs on the server machine as a server process and has essentially access to everything. Client side javascript is very restricted and has access to very little.
Author: duncanb7 replied at 2024-11-02 10:57:25
I know what you mean but I could Not find those tutorial
and adding back
HTML
HEAD
SCRIPT
BODY
for Node.js
I am trying to convincing myself to use Node.js for server-side javascript
by benchmarking server and client-side javascript code, I think I will replace
PHP code by Node.js if the benchmarking is good for Node.js for futur projects
I wonder why server code will run faster or compatiable to client-side javascript code
If comparing code writing effeciency or compact, I think Node.js is better than
PHP code but it might not be as good execution speed as client-side Javascript.
and adding back
HTML
HEAD
SCRIPT
BODY
for Node.js
I am trying to convincing myself to use Node.js for server-side javascript
by benchmarking server and client-side javascript code, I think I will replace
PHP code by Node.js if the benchmarking is good for Node.js for futur projects
I wonder why server code will run faster or compatiable to client-side javascript code
If comparing code writing effeciency or compact, I think Node.js is better than
PHP code but it might not be as good execution speed as client-side Javascript.
Expert: Dave Baldwin replied at 2024-11-02 10:47:30
It's probably because in 'setInterval.js' you are not sending a complete page like you did in 'setInterval.html'. In 'setInterval.js', all you are sending is the link so that is the entire page. If you want them to 'look the same', you have to send the same thing - a complete page.
In addition, the server side loop in 'setInterval.js' is Never seen by the browser. The browser makes a single request and gets a single response. The server code does not act the same as the browser code. Things like loops and other programming are done On the server and Not in the browser.
And by the way, this question and node.js have nothing to do with PHP. Node.js can't run the PHP interpreter though it could possibly call a command line PHP program. In such a case, functions that use server variables and cookies will not work because there is no web server to receive them and pass them on to PHP.
In addition, the server side loop in 'setInterval.js' is Never seen by the browser. The browser makes a single request and gets a single response. The server code does not act the same as the browser code. Things like loops and other programming are done On the server and Not in the browser.
And by the way, this question and node.js have nothing to do with PHP. Node.js can't run the PHP interpreter though it could possibly call a command line PHP program. In such a case, functions that use server variables and cookies will not work because there is no web server to receive them and pass them on to PHP.