PDA

View Full Version : Alerts



wanapitei
02-21-2008, 04:10 PM
I'm preparing a new website. During the preview period I would like to put up a welcome Alert message. I found this bit of JavaScript elsewhere (http://www.javascript-page.com/alert.html):


<script language="Javascript">

<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

alert ("This is a Javascript Alert")
//-->

</script>

However this routine doesn't let me put line returns into my text and it includes the current URL in bold as the headline, not what I'd prefer. You can preview it here (http://www.morleychalmers.com/MostlyTheravada/mtindex.html) (although the site is still crude). I'd prefer an alert that's a bit nicer. Any recommendations?

Appreciated.

jscheuer1
02-21-2008, 04:28 PM
Alerts do that in some browsers. You could try a DHTML pop up:

http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

or just put something right on the page that says:

"Under Construction"

wanapitei
02-21-2008, 06:09 PM
Alerts do that in some browsers. You could try a DHTML pop up:

http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

Something's wrong. Followed the same procedures I successfully did with Omnislide. Moved the CSS and JS files into their appropriate locations in the media directory (media/css/dhtmlwindow.css, and media/js/dhtmlwindow.js).

Made this edit to the demo file:


<link rel="stylesheet" href="../media/css/dhtmlwindow.css" type="text/css" />

<script type="text/javascript" src="../media/js/dhtmlwindow.js"></script>


This addressing approach works fine with Omnislide but not for Dhtml Window on my Mac. Therefore I switch to absolute addressing and put the demo on my website (http://www.morleychalmers.com/MostlyTheravada/demo1.htm) and place the css and js files in the appropriate media folders. Thus:


<link rel="stylesheet" href="http://www.morleychalmers/MostlyTheravada/media/css/dhtmlwindow.css" type="text/css" />

<script type="text/javascript" src="http://www.morleychalmers/MostlyTheravada/media/js/dhtmlwindow.js"></script>


Still doesn't work. I'm probably missing something obvious but I can't see it. Anyone spot the issue?

Appreciated.

Boxer
02-21-2008, 06:24 PM
You missed the top level domain (.com / .net / .org / whatever you have) and your script cannot be loaded.
And why do you put it in another file? Users' browsers will need to do an extra request - that's not good. You better place the JavaScript code right into the HTML page, in <script> container, and CSS in the header of the page, in <style> container, and everything will load and run on a single page. Faster and no errors :)

jscheuer1
02-21-2008, 06:25 PM
That's true, and unlike with omnislide, there is also code you need to put on your page for this script. Refer to Stage 2 on the demo page.

Please post a link to the page on your site that contains the problematic code so we can check it out.

Twey
02-21-2008, 06:58 PM
I was unsure whether to laugh or cry at the attempt to put a credit notice on a single alert() statement...

jscheuer1
02-21-2008, 07:06 PM
I was unsure whether to laugh or cry at the attempt to put a credit notice on a single alert() statement...

LOL, I didn't even notice that!

wanapitei
02-21-2008, 08:14 PM
That's true, and unlike with omnislide, there is also code you need to put on your page for this script. Refer to Stage 2 on the demo page.

I got fooled by the demo file working just fine "right out of the box". Oddly, by just changing the location of where to find the supporting CSS and JS files, it broke.


Please post a link to the page on your site that contains the problematic code so we can check it out.

There indeed was a URL to a demo, now removed. Here's the new, now revised demo (http://www.morleychalmers.com/MostlyTheravada/mtindex.html), with a different set of issues.

I'm using the ajax option here, pointing to the previewAlert (http://www.morleychalmers.com/MostlyTheravada/previewAlert.html) file on my site. However the CSS code in this file is being ignored for some reason. Not only are the margin calls ignored, so is the type point size. I'm missing something here.

Also, on this Mac the Minimize and Close widget images are coming up as "image ?", which is odd in that the widgets appear just fine on this Mac when going to DHTML Window (http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm).

Thanks for pointing out this Alert utility, much better than the other one.

jscheuer1
02-22-2008, 03:02 AM
Paths (like to images or links) on a page imported via AJAX will be relative to the page that imports it (the 'top' page), not to the imported page - if there is any doubt, use the absolute path. With css, the link to the css should be put on and set relative to the 'top' page, if it is a style section, not a link - it should be on the 'top' page. Paths in the css style declarations (if any - like for background images) should be relative to (if external) that css file. If it is a style section, as I say it should be on the 'top' page, and its paths will be relative to that 'top' page. Once again, use absolute paths whenever in doubt.

djr33
02-22-2008, 04:23 AM
<script type="text/javascript">
<!--
//This copyright notice is copyrighted under the terms stated here.//
-->
</script>

Twey
02-22-2008, 11:09 AM
Haha :D I liked cr3's old sig: "This text is ROT-26 encrypted, by reading it you are breaking the DMCA."

wanapitei
02-22-2008, 05:22 PM
Paths (like to images or links) on a page imported via AJAX will be relative to the page that imports it (the 'top' page), not to the imported page - if there is any doubt, use the absolute path. With css, the link to the css should be put on and set relative to the 'top' page, if it is a style section, not a link - it should be on the 'top' page. Paths in the css style declarations (if any - like for background images) should be relative to (if external) that css file. If it is a style section, as I say it should be on the 'top' page, and its paths will be relative to that 'top' page. Once again, use absolute paths whenever in doubt.

Here's a link to the current version (http://www.morleychalmers.com/MostlyTheravada/mtindex.html). On this Mac there's question marks where the minimize and close icons should appear. Oddly, I have no difficulty seeing those icons when I go here (http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm).

I solved the CSS problem two ways. I put the CSS code for the ajax dhtml window into the dhtmlwindow.css file and, just to be sure I also used absolute addressing. One or the other of them made the difference.

I've been trying to use relative addressing rather than absolute so I can test locally, rather than having to upload and then run. Of course, eventually these files will move to the mostlytheravada.org server once it's been set up so all these absolute linkages will need to be revised. Nevertheless, we're very close to having a half decent site ready for previewing. I'm not at all happy with the home page graphics, but that's another issue. At least content and navigation, thanks to omnislide, is working and looks pretty good.

Please let me know what to do about those missing widget graphics. Don't know yet whether they fail on PCs as well as Macs.

Appreciated.

thetestingsite
02-22-2008, 05:35 PM
I can't seem to find where you uploaded the images, but the paths to them are not correct in the js file. You need to fix the paths on this line of the js file:



var dhtmlwindow={
imagefiles:['windowfiles/min.gif', 'windowfiles/close.gif', 'windowfiles/restore.gif', 'windowfiles/resize.gif'], //Path to 4 images used by script, in that order


Hope this helps.

jscheuer1
02-22-2008, 05:40 PM
Whatever works for you on the style. If you just put it on the top page (/MostlyTheravada/mtindex.html), there would be no problem.

These are the paths to the images:


http://www.morleychalmers.com/MostlyTheravada/windowfiles/min.gif

and:

http://www.morleychalmers.com/MostlyTheravada/windowfiles/close.gif

They're not there in those locations.

wanapitei
02-22-2008, 05:51 PM
I can't seem to find where you uploaded the images, but the paths to them are not correct in the js file. You need to fix the paths on this line of the js file:



var dhtmlwindow={
imagefiles:['windowfiles/min.gif', 'windowfiles/close.gif', 'windowfiles/restore.gif', 'windowfiles/resize.gif'], //Path to 4 images used by script, in that order


Hope this helps.

Thanks, that solved it. Much appreciated.