Mellor: DHTML - Learning by Example.
FAQs
Question |
Comment |
I want to date-mark my HTML files so people can see when the last update was, is there an automatic way of doing this ? |
The best way is to have an onLoad event handler in the BODY statement calling a function, which in turn contains: document.write("updated on " + document.lastModified) or similar. |
How can I put page breaks in HTML sides ? |
You do that by setting up a class of page breaks. <STYLE TYPE="text/css"> P.breakhere {page-break-before: always} </STYLE>
This then will be the activator for the page break:
<P CLASS="breakhere"> You can set up as many different classes as you'd like as long as you keep following the same format as above (or similar). |
I'm having trouble with pop-up boxes. How do I open new windows of a certain size? At the moment I'm using HTML code <target="_blank"> and trying to specify the new windows size in the new HTML document. |
Older browsers will not recognise the "resize" method, so use "open" instead. Write a function in HEAD thus: function box(URL) {window.open(URL,'box','menubar=yes,status=no,resizable=yes,scrollbars=yes,width=30,height=20')} and call it using: <a href="javascript:box('file.htm')">open file</a> But remember you can only call the function "box" once, meaning you can only have one new window open at a time. If you want several, you will have to repeat the function (name it box2) and call it using: <a href="javascript:box2('file2.htm')"> |
Apparently some people keep visiting HTML files which should properly be viewed in frames. Is there a way to fix this ? |
If your visitors are in a frame then you can use "location", like: parent.contents.location="menu.htm" but if your visitors are totally outside of the frame then a little more force has to be used, the most elegant way is to use an IF statement to compare "self" to "parent" and use the outcome to refresh to a different URL: if (self==parent){
Note that this code must be in HEAD |
Is there any way I can "count-down" a clock on a page ? |
Look at the following code, calling "startclock" sets a loop running that clears timeout, displays the current time, and set timeout to re-display the time in 2 seconds. Use it as inspiration, it should contain all the ingredients you need, but find your own answers. var timerID=null;
|
Can I use a Prompt box in connection with a hyperlink to ask visitors if they really want to visit that link ? |
Of course, but perhaps a Confirm box is better, and open a new window, to make it easy for your visitor to return: If (confirm("are u sure") {
|
What is VBS ? |
VBS stands for Visual Basic Script and is not used client-side on the Internet. VBS should not be confused with VBScript. VBS can start, use, and shut down PC applications without client (user) knowledge. If you receive uninvited VBS files (the extension is vbs; e.g. fileName.vbs) by mail or embedded in HTML files, then you should immediately delete them as they can easily be malicious programs or virus's. |
What is IP ? |
Internet Protocol. The low-level part of the TCP/IP protocol. IP assembles the packets, adds address information and dispatches them over the network. IP has nothing directly to do with DHTML. |
I cannot call functions in external files |
The newer browsers, MS Internet Explorer 5.5 and Netscape6, do not wait to read in whole external files, so: <SCRIPT SRC="FileWithFunctionIn.js">
may well not work in these browsers. The work-around is to divide them such that the browser pauses and reads in the code before continuing to the next block: <SCRIPT SRC="FileWithFunctionIn.js">
|
Is there any way of getting the "Object" tag to work in Netscape. |
Not precisely, but you can combine the Object and Embed tags: <object classid="" height="" width="">
So if neither the Object tag nor the Embed tag works in that browser, then at least a default image is shown instead. |
In Example R the classID registry value for ActiveX was given, are there any more useful classIDs ? |
Sure: ActiveX: CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83" Flash: CLASSID="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" Shockwave: CLASSID="CLSID:166B1BCA-3F9C-11cf-8075-444553540000" RealMedia: CLASSID="CLSID:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" Class ID is most often assigned by the developers computer when the control is first created. They are managed partly through the Windows registry, and are thus difficult to see and manipulate. However you can find out more by using special tools, such as the Microsoft OLE/COM Object Viewer. The Viewer is distributed with the Windows NT Resource Kit - see http://www.microsoft.com/resources/oleview.asp |