Forum Moderators: open

Message Too Old, No Replies

Validation not liking javascript/dhtml

XHTML transitional

         

Sypher_5

8:03 am on Dec 10, 2003 (gmt 0)

10+ Year Member



I'm using,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

As my doc type.


<script type="text/javascript">
<![CDATA[
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function MM_displayStatusMsg(msgStr) { //v1.0
status=msgStr;
document.MM_returnValue=true;
}
]]>
</script>

As my Function in the head section.

<a href='javascript:null()' OnClick="MM_openBrWindow('http://url.com/page.html','Download','TOOLBAR=0,LOCATION=0,DIRECTORIES=0,STATUS=0,MENU BAR=0,SCROLLBARS=0,RESIZEABLE=0,LEFT=140,TOP=50,WIDTH=356,HEIGHT=240')"><img src='download.gif' alt='download' align='right' id='dl' /></a>

As my link to open a popup with a download on it.

When I validate it, this is now the last remaining issue I have. I originally had the onclick in the img tag, it didn't like it there either. So my question is, how do I go about opening my popup and keeping in compliance with my Doctype? I can have more than one popup per page depending on the content of my pages, this is the nicest popup function I've found that can handle multiple windows at one time. ( preview, download, etc )

birdbrain

11:49 am on Dec 10, 2003 (gmt 0)



Hi there Sypher_5,


there is no attribute "OnClick"


is rather misleading...I had the same problem myself.
There is an attribute 'OnClick but you must type it...


onclick

xhtml has to be lower case.

birdbrain

Sypher_5

2:18 pm on Dec 13, 2003 (gmt 0)

10+ Year Member



To validate as XHTML I have to do this..

<script language="JavaScript type="text/javascript">
<![CDATA[

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function MM_displayStatusMsg(msgStr) { //v1.0
status=msgStr;
document.MM_returnValue=true;
}

]]>
</script>

And it breaks the script, I thought using transitional would mean I could still use popups?

Removing the CDATA makes it work again but the page nolonger validates. Is there anyway to fix this?

tedster

11:03 pm on Dec 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I prefer to call javascript functions from external .js files rather than the head section. This avoids many painful surprises, and you don't need to get into the CDATA mess with the script in an external file.

One other comment -- you can use javascript in strict XHTML as well as transitional, but what you can't use to open a new window is the target attribute. Same issue comes up in HTML 4.01 strict vs. transitional.