Hi,
Is that posible to create a web page completely with javascript and open it
without request to server? Please show a simple sample. Thanks in advance!
Jack 16 23255
"datactrl" <qu***@tpg.com.au> wrote in message
news:41********@dnews.tpgi.com.au... Hi,
Is that posible to create a web page completely with javascript and open
it without request to server? Please show a simple sample. Thanks in advance!
Jack
A Web page is delivered by a Web server....
Of course you can create a file with an .htm (or .html) extension and
double-click on it in Windows Explorer and it will open. No JavaScript is
necessary to do this; for example:
<html>
<head>
<title>test1.htm</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
You can create a page using javascript :
<html>
<head>
<title>test2.htm<title>
<script type="text/javascript">
var htm = "<html>";
htm += "<head>";
htm += "<title>test3.htm;
htm += "</head>";
htm += "<body>";
htm += "<h1>Hello World</h1>";
htm += "</body>";
htm += "</html>";
document.write(htm);
</script>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Does this answer your question? If not please clarify.
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Con9d.352861$Fg5.74302@attbi_s53... "datactrl" <qu***@tpg.com.au> wrote in message news:41********@dnews.tpgi.com.au... Hi,
Is that posible to create a web page completely with javascript and open it without request to server? Please show a simple sample. Thanks in
advance! Jack
A Web page is delivered by a Web server....
Of course you can create a file with an .htm (or .html) extension and double-click on it in Windows Explorer and it will open. No JavaScript is necessary to do this; for example:
<html> <head> <title>test1.htm</title> </head> <body> <h1>Hello World</h1> </body> </html>
You can create a page using javascript:
<html> <head> <title>test2.htm<title> <script type="text/javascript"> var htm = "<html>"; htm += "<head>"; htm += "<title>test3.htm; htm += "</head>"; htm += "<body>"; htm += "<h1>Hello World</h1>"; htm += "</body>"; htm += "</html>"; document.write(htm); </script> </head> <body> <h1>Hello World</h1> </body> </html>
Does this answer your question? If not please clarify.
Of course
htm += "<title>test3.htm;
should have been
htm += "<title>test3.htm</title>";
Here's another possibility.
var htm = "<html>";
htm += "<head>";
htm += "<title>test4.htm</title>";
htm += "</head>";
htm += "<body>";
htm += "<h1>Hello World</h1>";
htm += "</body>";
htm += "</html>";
var oIE = new ActiveXObject("InternetExplorer.Application");
oIE.visible = true;
oIE.navigate("about :blank");
oIE.document.open;
oIE.document.write(htm);
oIE.document.close;
datactrl said: Hi,
Is that posible to create a web page completely with javascript and open it without request to server? Please show a simple sample. Thanks in advance!
Sure it is, but it has to be loaded from someplace, and it's also very
simple to store a complete web page on the local disk. What, exactly,
are you looking for?
Thanks a lot, McKirahan. The last one is what I want. I would like to pop up
a web page which is completely created by the original page with javascript.
How about if I want to use showModelessDialog() to open it, is that
possible? Thanks again !
Jack
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:BAn9d.209130$D%.75621@attbi_s51... "McKirahan" <Ne**@McKirahan.com> wrote in message news:Con9d.352861$Fg5.74302@attbi_s53... "datactrl" <qu***@tpg.com.au> wrote in message news:41********@dnews.tpgi.com.au... Hi,
Is that posible to create a web page completely with javascript and
open it without request to server? Please show a simple sample. Thanks in advance! Jack
A Web page is delivered by a Web server....
Of course you can create a file with an .htm (or .html) extension and double-click on it in Windows Explorer and it will open. No JavaScript
is necessary to do this; for example:
<html> <head> <title>test1.htm</title> </head> <body> <h1>Hello World</h1> </body> </html>
You can create a page using javascript:
<html> <head> <title>test2.htm<title> <script type="text/javascript"> var htm = "<html>"; htm += "<head>"; htm += "<title>test3.htm; htm += "</head>"; htm += "<body>"; htm += "<h1>Hello World</h1>"; htm += "</body>"; htm += "</html>"; document.write(htm); </script> </head> <body> <h1>Hello World</h1> </body> </html>
Does this answer your question? If not please clarify.
Of course htm += "<title>test3.htm; should have been htm += "<title>test3.htm</title>";
Here's another possibility.
var htm = "<html>"; htm += "<head>"; htm += "<title>test4.htm</title>"; htm += "</head>"; htm += "<body>"; htm += "<h1>Hello World</h1>"; htm += "</body>"; htm += "</html>"; var oIE = new ActiveXObject("InternetExplorer.Application"); oIE.visible = true; oIE.navigate("about:blank"); oIE.document.open; oIE.document.write(htm); oIE.document.close;
Have a search for a message subject "writing slabs of htm".
It was conclusively shown by Lasse that it is much quicker
to write HTML as elements in array, then use join("") to
concatenate them before writing to the page. The length of
time taken using += verus join() is exponentially longer,
getting seriously long for big pages.
There is an example of how to use it below.
Of course, if your content is only small...
Cheers, Rob.
<html>
<head>
<title>Slabs of HTML</title>
</head>
<body>
<script type="text/javascript">
var a = [];
var i = 0;
a[0] = " <p>here is paragraph " + i + "</p>";
a[++i] = " <p>here is paragraph " + i + "</p>";
a[++i] = " <p>here is paragraph " + i + "</p>";
a[++i] = " <table border='1' cellpadding='5' cellspacing='10'>";
a[++i] = " <tr>";
a[++i] = " <td>This is a cell</td>";
a[++i] = " <td>another cell</td>";
a[++i] = " </tr>";
a[++i] = " <tr>";
a[++i] = " <td>This is a cell</td>";
a[++i] = " <td>another cell</td>";
a[++i] = " </tr>";
a[++i] = " <tr>";
a[++i] = " <td colspan='2' align='center'>";
a[++i] = " <form name='fred' action=''>";
a[++i] = " <input type='text' name='aTxt' width='50'>";
a[++i] = " <input type='button' value='click me'"
+ "
onclick=\"alert(this.form.aTxt.value);\"><br>";
a[++i] = " <input type='reset' value='Reset'>";
a[++i] = " </form>";
a[++i] = " </td>";
a[++i] = " </tr>";
a[++i] = "</table>";
var s = a.join("");
document.write(s);
</script>
</body>
</html>
Thank's Rob. My question is that I would like to popup a web page from an
already displayed page. And the popup page would like to be created from the
already displayed page with javascript. I think the way using
document.write() will change the content of already displayed page. That is
not the question.
I've tried 'new ActiveXObject("InternetExplorer.Application");' sample
provided by McKirahan. I think that would let me open an another window for
the created page. But I got an "automation error" when I run this sample.
Don't know what it is.
Jack
"RobG" <rg***@iinet.net.auau> wrote in message
news:Uy*****************@news.optus.net.au... Have a search for a message subject "writing slabs of htm". It was conclusively shown by Lasse that it is much quicker to write HTML as elements in array, then use join("") to concatenate them before writing to the page. The length of time taken using += verus join() is exponentially longer, getting seriously long for big pages.
There is an example of how to use it below.
Of course, if your content is only small...
Cheers, Rob.
<html> <head> <title>Slabs of HTML</title> </head> <body> <script type="text/javascript"> var a = []; var i = 0; a[0] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <table border='1' cellpadding='5' cellspacing='10'>"; a[++i] = " <tr>"; a[++i] = " <td>This is a cell</td>"; a[++i] = " <td>another cell</td>"; a[++i] = " </tr>"; a[++i] = " <tr>"; a[++i] = " <td>This is a cell</td>"; a[++i] = " <td>another cell</td>"; a[++i] = " </tr>"; a[++i] = " <tr>"; a[++i] = " <td colspan='2' align='center'>"; a[++i] = " <form name='fred' action=''>"; a[++i] = " <input type='text' name='aTxt' width='50'>"; a[++i] = " <input type='button' value='click me'" + " onclick=\"alert(this.form.aTxt.value);\"><br>"; a[++i] = " <input type='reset' value='Reset'>"; a[++i] = " </form>"; a[++i] = " </td>"; a[++i] = " </tr>"; a[++i] = "</table>";
var s = a.join("");
document.write(s);
</script> </body> </html>
datactrl wrote: Thank's Rob. My question is that I would like to popup a web page from an already displayed page. And the popup page would like to be created from the already displayed page with javascript. I think the way using document.write() will change the content of already displayed page. That is not the question.
If you want to open a modal dialog from the newly generated page, just include an onLoad evend in
<body> tag:
....
a[0] = "<body onLoad='javascript:showModalDialog(<your parameters>)'>"
....
a[<last>] = "</body>"
I've tried 'new ActiveXObject("InternetExplorer.Application");' sample provided by McKirahan. I think that would let me open an another window for the created page. But I got an "automation error" when I run this sample. Don't know what it is.
It should be a security issue, if you run this from a web server, which is not on your local
machine. So if you want to have a web server where clients access remotely, you shouldn't use
ActiveXObject - just use document.write.
Jack
"RobG" <rg***@iinet.net.auau> wrote in message news:Uy*****************@news.optus.net.au...
Have a search for a message subject "writing slabs of htm". It was conclusively shown by Lasse that it is much quicker to write HTML as elements in array, then use join("") to concatenate them before writing to the page. The length of time taken using += verus join() is exponentially longer, getting seriously long for big pages.
There is an example of how to use it below.
Of course, if your content is only small...
Cheers, Rob.
<html> <head> <title>Slabs of HTML</title> </head> <body> <script type="text/javascript"> var a = []; var i = 0; a[0] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <table border='1' cellpadding='5' cellspacing='10'>"; a[++i] = " <tr>"; a[++i] = " <td>This is a cell</td>"; a[++i] = " <td>another cell</td>"; a[++i] = " </tr>"; a[++i] = " <tr>"; a[++i] = " <td>This is a cell</td>"; a[++i] = " <td>another cell</td>"; a[++i] = " </tr>"; a[++i] = " <tr>"; a[++i] = " <td colspan='2' align='center'>"; a[++i] = " <form name='fred' action=''>"; a[++i] = " <input type='text' name='aTxt' width='50'>"; a[++i] = " <input type='button' value='click me'" + " onclick=\"alert(this.form.aTxt.value);\"><br>" ; a[++i] = " <input type='reset' value='Reset'>"; a[++i] = " </form>"; a[++i] = " </td>"; a[++i] = " </tr>"; a[++i] = "</table>";
var s = a.join("");
document.write(s);
</script> </body> </html>
datactrl wrote: Thank's Rob. My question is that I would like to popup a web page from an already displayed page. And the popup page would like to be created from the already displayed page with javascript. I think the way using document.write() will change the content of already displayed page. That is not the question.
[snip]
If you want the content in a new window, then create a new window called
(say) newWindow and write to it:
newWindow = window.open('','Window Title','parameters....');
...
slabs of HTML
...
newWindow.document.write(s);
Then the HTML appears in newWindow, not the current one.
Cheers, Rob.
RobG said: datactrl wrote: Thank's Rob. My question is that I would like to popup a web page from an already displayed page. And the popup page would like to be created from the already displayed page with javascript. I think the way using document.write() will change the content of already displayed page. That is not the question. [snip]
If you want the content in a new window, then create a new window called (say) newWindow and write to it:
newWindow = window.open('','Window Title','parameters....');
...
slabs of HTML
...
newWindow.document.write(s); Then the HTML appears in newWindow, not the current one.
Sometimes. But sometimes you get an error because newWindow.document
has no properties, because the O/S hasn't opened the new window fast
enough, so you're trying to write into a window that isn't ready.
globalHTML=s;
window.open("javascript :opener.globalHTML");
is more reliable.
JRS: In article <Uy*****************@news.optus.net.au>, dated Fri, 8
Oct 2004 05:27:16, seen in news:comp.lang.javascript, RobG
<rg***@iinet.net.auau> posted : var a = []; var i = 0; a[0] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <p>here is paragraph " + i + "</p>"; a[++i] = " <p>here is paragraph " + i + "</p>";
If you use i++ rather than ++i, then the first line can have the same
LHS as the rest, and the first para will be paragraph 1 - ISTM.
How about
var s = [
" <p>here is paragraph " + 1 + "</p>",
" <p>here is paragraph 2 </p>",
" <p>here is paragraph 3 </p>",
...
"" ].join("") ;
taking the view that self-numbering paragraphs are probably not needed?
The empty string is to allow the previous line to end, like the rest,
with a comma, which seems nicer.
I've not tested for speed.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Now I do as following:
<html>
<head>
<title>pop up a window on fly</title>
<script type="text/javascript">
//function PopUpWindow(){
var sHtm = ["<html>",
"<head>",
"<title>popup htm</title>",
"</head>",
"<body>",
"<h1>Hello World</h1>",
"</body>",
"</html>"].join("");
// var s1 =
"dialogHeight=160px;dialogWidth=300px;help=no;stat us=no;resizeable=no";
// window.showModelessDialog("javascript:opener.sHtm" ,"",s1);
window.open("javascript:opener.sHtm");
//}
</script>
</head>
<body>
<p>This is the calling window</P>
<button onClick="PopUpWindow()">popup</button>
</body>
</html>
This one works. But if I use button click to run PopUupWindow() or use
showModelessDialog() it won't work at all.
Jack
datactrl said: Now I do as following: <html> <head> <title>pop up a window on fly</title> <script type="text/javascript"> //function PopUpWindow(){ var sHtm = ["<html>", "<head>", "<title>popup htm</title>", "</head>", "<body>", "<h1>Hello World</h1>", "</body>", "</html>"].join(""); // var s1 = "dialogHeight=160px;dialogWidth=300px;help=no;sta tus=no;resizeable=no"; // window.showModelessDialog("javascript:opener.sHtm" ,"",s1); window.open("javascript:opener.sHtm"); //} </script> </head> <body> <p>This is the calling window</P> <button onClick="PopUpWindow()">popup</button> </body> </html>
This one works. But if I use button click to run PopUupWindow() or use showModelessDialog() it won't work at all.
Because you've made sHtm *local* to the function PopUpWindow().
In order to work, it must be a *global* variable.
Get rid of the "var" keyword.
> Because you've made sHtm *local* to the function PopUpWindow(). In order to work, it must be a *global* variable. Get rid of the "var" keyword.
Thanks a lot Lee. Once sHtm is made as global it works. By the way, how
about using ShowModalDialog() or showModelessDialog(). It always showed
"error: opener.sHtm is null or not an object".
Jack
datactrl wrote:
[snip] Thanks a lot Lee. Once sHtm is made as global it works. By the way, how about using ShowModalDialog() or showModelessDialog(). It always showed "error: opener.sHtm is null or not an object".
[snip]
Those are IE only functions and are therefore shunned by
anyone wishing to create platform independent code - which,
after all, was the point of the internet and WWW in the
first place.
Cheers, Rob.
Dr John Stockton wrote:
[snip] If you use i++ rather than ++i, then the first line can have the same LHS as the rest, and the first para will be paragraph 1 - ISTM.
How about var s = [ " <p>here is paragraph " + 1 + "</p>", " <p>here is paragraph 2 </p>", " <p>here is paragraph 3 </p>", ... "" ].join("") ;
taking the view that self-numbering paragraphs are probably not needed?
Looks great. I auto-numbered the paras just for the sake of
it, no real purpose.
Rob.
> Sometimes. But sometimes you get an error because newWindow.document has no properties, because the O/S hasn't opened the new window fast enough, so you're trying to write into a window that isn't ready.
globalHTML=s; window.open("javascript:opener.globalHTML");
is more reliable.
This works fine. But sometimes it will open a blank window without any
content. Is there any way to work arround this problem? Thanks in advance!
Jack This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joe Finsterwald |
last post by:
Recently I needed to add a confirm to a LinkButton that called a
JavaScript function on success, and did nothing on failure. I found
documentation on adding a confirm, but not on how to place a...
|
by: Axel Dahmen |
last post by:
Hi,
I can't create local fragment hyperlinks or JavaScript hyperlinks in
ASP.NET. It always appends the current path to any value. How can I switch
that off?
Examples:
* ...
|
by: Jensen bredal |
last post by:
Hello,
I have some javascript on my page but i can see that these scripts are not
beeing run on post back.
The only run the first the page loads. Is there a way to tell the "Page
object" tu run...
|
by: philmaz |
last post by:
What I am trying to do is create a form that people can use to enter
their email address to sign up for a mailing list. Once they enter
their email address, I want the script to open up a txt file...
|
by: theseer |
last post by:
I need to create an application where I need to obtain variables from
one page and pass that to a javascript function on another. Is it
possible to pass variables from one page into a JS function...
|
by: GroupReader |
last post by:
I posted a similar question earlier and got lots of good feedback, but
now I have more information:
Problem: I have javascript in a user control that is not "loading"
properly. When I try to...
|
by: Suresh Sharma |
last post by:
i want to know how to create page dynamically like Sulekha.com
which show his record per html page through programm.
I am working on project such like this and i want to implement like this?
...
|
by: plsHelpMe |
last post by:
How to create dynamic javascript arrays using dojo toolkits
Hello frens,
I am in a big trouble. My objective is:
I am having some categories shown by differnent radio buttons, on the click of...
|
by: pankajsingh5k |
last post by:
Dear All,
Please help me...
I had read an article to lazy load a tab in a tabcontainer using an update panel on
http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |