Javascript: Valid For XHTML And Cross Browsers?

Jul 26, 2006

I'm considering in teaching myself some javascript, but before I take the time to read up and experiment, I had a few questions.

Is javascript XHTML 1.0 STRICT Valid?
Is javascript valid for any version of XHTML?
Is javascript easily cross browser compatiable, or will this take a long time to work around?

View 11 Replies


ADVERTISEMENT

XHTML 1.1 Valid Aligning

Apr 24, 2007

An easy XHTML1.1 valid way of aligning divsfunction XHTMLAlign(tagid, align){

var viewportwidth;
var viewportheight;

// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

if (typeof window.innerWidth != 'undefined')
{
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
}

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth !=
'undefined' && document.documentElement.clientWidth != 0)
{
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight
}

// older versions of IE

else
{
viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
viewportheight = document.getElementsByTagName('body')[0].clientHeight
}

var tag = document.getElementById(tagid);
tag.style.position="absolute";
if(tag.style.marginLeft == ""){
tag.style.marginLeft = "0";
}
if(tag.style.marginRight == ""){
tag.style.marginRight = "0";
}
if(tag.style.marginTop == ""){
tag.style.marginTop = "0";
}
if(tag.style.marginBottom == ""){
tag.style.marginBottom = "0";
}
if(tag.style.width == ""){
if (tag.width != ""){
tag.style.width = tag.width;
} else {
tag.style.width = "0";
}
}
if(tag.style.height == ""){
if (tag.height != ""){
tag.style.height = tag.height;
} else {
tag.style.height = "0";
}
}
if ( align=="left" ){
tag.style.left=parseInt(tag.style.marginLeft) + "px";
tag.style.right= viewportwidth - (parseInt(tag.style.width) + parseInt(tag.style.marginLeft)) + "px";
} else if ( align=="right" ){
tag.style.right=parseInt(tag.style.marginLeft) + "px";
tag.style.left=viewportwidth - (parseInt(tag.style.width) + parseInt(tag.style.marginRight)) + "px";
} else if ( align=="center" ){
tag.style.right= ((viewportwidth - parseInt(tag.style.width))/2) - parseInt(tag.style.marginLeft) + parseInt(tag.style.marginRight) + "px";
tag.style.left= ((viewportwidth - parseInt(tag.style.width))/2) + parseInt(tag.style.marginLeft) - parseInt(tag.style.marginRight) + "px";
}
if ( align=="top" ){
tag.style.top=parseInt(tag.style.marginTop) + "px";
tag.style.bottom= viewportheight - (parseInt(tag.style.bottom) + parseInt(tag.style.marginTop)) + "px";
} else if ( align=="bottom" ){
tag.style.bottom=parseInt(tag.style.marginTop) + "px";
tag.style.top=viewportheight - (parseInt(tag.style.width) + parseInt(tag.style.marginBottom)) + "px";
} else if ( align=="vcenter" ){
tag.style.bottom= ((viewportheight - parseInt(tag.style.width))/2) - parseInt(tag.style.marginTop) + parseInt(tag.style.marginBottom) + "px";
tag.style.top= ((viewportheight - parseInt(tag.style.width))/2) + parseInt(tag.style.marginTop) - parseInt(tag.style.marginBottom) + "px";
}
return;
}


setInterval('XHTMLAlign("divid", "center")', 100);
setInterval('XHTMLAlign("divid", "vcenter")', 100);

View 2 Replies View Related

Code - Cross Browsers Tabs

Sep 30, 2010

I am having some problems with some JS code that does not work cross browsers

Here is my code

Code:

CSS

Code:

JS

Code:

View 3 Replies View Related

JS Code That Does Not Work Cross Browsers ?

Sep 30, 2010

I am having some problems with some JS code that does not work cross browsers

Here is my code

Code:

CSS

Code:

JS

Code:

View 1 Replies View Related

Looking For A Cross-browsers Vertical Scrolling Script

Mar 12, 2006

I am wondering if someone know of a free cross-browsers vertical scrolling script that:

- is cross cross-browsers

- will call the scrolling content from an external html page or from a url page

- will also has an option to pause when each heading on the content page
reach the top or bottom of defined scrolling window, depending on the
predefined direction the scroll is scrolling.

View 2 Replies View Related

Element SetAttribute() Method - Valid Method Of Changing The Id Of An XHTML Element

Feb 24, 2010

Is the form below a valid method of changing the id of an XHTML element, specifically the one actually being referenced? It does not seem to work for me.

document.getElementById("Original_Name").setAttribute("id", "New_name");

View 4 Replies View Related

Xhtml W/javascript And Css Only Works In IE

Jul 23, 2005

There are two main things which I am trying to work through:

Drop down menu (bottom of page) - which only works in IE (on pc) right
now, although it should work on all browsers except opera.
Traditionally in a HTML 4.0 Transitional environment.

Div content that scrolls - placed correctly and works in IE and that's
it. Here is an example of the working script on another site
http://www.dyn-web.com/dhtml/scroll/scroll-rel.html . Traditionally in
a Xhml strict.

My goal is to get this page to look as good in Netscape and on the mac
as it already does in IE.

View 2 Replies View Related

Xhtml Complient Javascript

Aug 6, 2004

the following line is erroring in an xhtml validator:

var ns6clock=document.getElementById && !document.all

the && is erroring, but I cant work out how to change it eg to the ascci value? Code:

View 10 Replies View Related

Javascript In Xhtml Strict

Jul 11, 2002

does anyone know of any sites that use (validating) xhtml strict, and also use javascript functions - rollovers etc?

(the strict dtd won't allow you to use the "name" attribute, in images, so I want to find out what the solution is to this problem)

View 4 Replies View Related

Valid Javascript?

Mar 11, 2003

I do not know javascript but I just wanted to check to see if this is valid javascript across all browsers that support js.

<script type="text/javascript">
function locate(page)
{
thePage='http://www.domain.net/' +page
window.location=thePage
}
</script>

<a href="#" onclick="locate('page.php'); return false;">Send</a>

It works in IE, should I expect any problems in any other browser?

View 7 Replies View Related

XHTML Javascript Image Swap Conflict

Jan 28, 2007

I am using a simple javascript image insertion on my XHTML page, and I have encountered a problem. The Javascript code fails to execute when the doctype is XHTML on Firefox (works on Opera). However, when I simply rename the file with an HTML extension, the code executes on all browsers. Code:

View 6 Replies View Related

Cross Frame Javascript Communication

Oct 28, 2003

I have set of frames... one contains a menu and the other a status frame. I am calling a function from the menu which sets the variables however I need some help passing those variables to the status frame. How would I go about doing such a thing?

This is called from the menu in frame 1 but doesn't work:

Code:
function jumpsec(cat, prod) {
parent.statusbar.category=cat;
parent.statusbar.product=prod;
}

// then my status frame bar has:
document.write(parent.statusbar.category);
document.write(parent.statusbar.product);

The 2 variables are blank on statusbar onload but get populated with each click.

View 4 Replies View Related

What Is Percentage Of Browsers With Disabled JavaScript ?

Dec 16, 2006

I am wondering if anybody can provide statistics what is percentage of visitors with disabled JavaScript.

Even more interesting would be statistics of users with disabled JavaScript making a purchase. I am more likely to purchase from my home than from work and I think the disabled JS is mostly result of IT dept. policies.

Is e-commerce site missing much if requires JavaScript?

View 7 Replies View Related

Javascript Code Same But Output Is Different On Different Browsers

Jun 7, 2007

Can any one tell me different functions or properties of javascript
which are gives different outputs on different browsers ?

View 3 Replies View Related

Maximum Javascript Code In IE Browsers...?

Apr 20, 2003

Q: I have a pretty big html page - about 1,500 lines of code, 1,000 of which is javascript. (It's also referencing other javascript code, perhaps another 2,000 lines or so).

When I boot up the page in a fresh browser, it invariably crashes; the page just hangs. But, after killing the browser, and opening it up in a new one, the page seems to run fine. Is there some sort of javascript code limit that a web page / browser can handle...? Anyone know if there's a way to get around this? [Did I misread the problem? I'm pretty sure my code is fine.] Code:

View 22 Replies View Related

JavaScript Blocked By New Version Browsers

Mar 19, 2005

I have a lot of JavaScript code I wrote to add special features and effects to my Web sites. The problem is, with the latest versions of Web browsers, all browser-side scripts are blocked. Most users who visits will either not know how to adjust their security features to allow scripts or will not want to change their settings. In a case where the script is vital to the functioning of the Web page, what is the alternative?

For example, one of my script is for a drop-down menu that takes the user to the selected section from the drop-down menu.

The other feature I need is roll-over that highlight parts of a map so that the user can make a selection.

Is there something I can add to my JavaScript code to prevent browsers from blocking it or is there a different way of using these features with a different script?

View 4 Replies View Related

Prevent JavaScript File Caching In All Browsers

May 14, 2007

I'm currently using this method to refer to my JavaScript files:

<script type="text/javascript" src="filename.js"></script>
While doing work for some clients I have made changes to the the JavaScript file referenced above. Because their browser has cached it, they end up getting errors on the page unless they hard refresh and get the new version of the file.

Is there anyway to make the JavaScript file come down fresh if it has been modified since the last download?

View 3 Replies View Related

Looking For A Specific Simple Cross-broswers Vertical Scrolling Javascript

Mar 21, 2006

Does anyone know a simple cross-broswers vertical scrolling javascript
that can call up its scrolling contents off an external html page/file?

View 1 Replies View Related

JQuery :: Ajax - On Safari/Chrome Browsers - Code Is Not Working On Webkit Browsers

Sep 26, 2009

Why this code is not working on Webkit browsers:

Only jquery and the plugin printed above are loaded, so there shouldn't be any conflicts.

HTML:

Chrome gives the following error: Uncaught TypeError: Object #<an Object> has no method 'followUser

View 10 Replies View Related

Cross Browser, Cross Domain Iframe Resizing Script?

Jun 18, 2009

Is there any way to resize an iframe dynamically to the height of its content that works cross browser and works when the iframe content is on another domain than the main page (I have access to both pages, so code can be put in either) Also, it must resize when links in the iframe are clicked (ie when a new page within the iframe is loaded)

View 1 Replies View Related

JavaScript In SVG "cross Compatability" With Window.open

Jul 23, 2005

I have a static .svg file with embedded onclick="open()"'s all over.

The svg is <embed>ded in a minimal .html file.

The onclick's work fine in IE w/Adobe SVG viewer 3: click and a new
window opens with the specified URL.

But using the Adobe SVG viewer in Mozilla, neither the mouseovers or
the onclicks work, although the image itself renders.

However, the PRIMARY problem that I need to fix is that the onclick's
don't work in Safari with the Adobe viewer. The mouseovers DO work,
but the onclick's do not.

I've tried specifying window.open() instead of just open(). I've also
tried changing the onclicks to call a function openNewWindow which in
turn calls window.open. Still no luck in safari.

I've also tried defining the openNewWindow function in the html
wrapper, and specifying a3:scriptImplementation="browser". In this
case, the SVG still functions as desired in IE, but neither the
mouseovers nor the onclicks work in Safari.

To summarize, I need to get a new window with a specified URL to open
on click for Safari with the Adobe SVG viewer 3.

View 4 Replies View Related

JQuery :: Get A True Cross-fade, Not The Sorta Cross Fade Used By Default?

May 27, 2011

Simple question really. The cross fade option used by default with cycle is not a linear one...it looks like it uses some kind of S curve because during the crossfade animation the background (meaning the area behind the images being cross-faded) becomes visible. Example screenshot taken mid-transition. The pink should never be visible behind the grey, but it is:

[Code]...

at the moment, which is leading to background visibility. Is there another fx option I should be using?

View 4 Replies View Related

Browsers Off Not Access <script Type="text/javascript" Src="...files?

Apr 17, 2009

just came across this in a book for browser javascript on/off detection:

Code:
<noscript>
<img src="monitor.php?scriptoff=true" />
</noscript>
just wondering if browsers when js is off will ever access any
<script type="text/javascript" src="file.js"></script>

files? i mean wouldn't it be better not to bother with the noscript thing and just be aware of if file.js is accessed? or do some browsers access the file.js even when js is off?

View 3 Replies View Related

XML In XHTML

Nov 30, 2005

I am trying to include and xml document inside my xhtml document. There
are a number of reasons for this including portability, multiple
interface generation, and scalability of information.
My problem is that javascript is understanding the nodes in my xml
document as html elements.

<xml>
<book>
<title>Lord of the Rings</title>
</book>
</xml>

If I parse this, the title element cannot be extracted and the page
title(in the browser) becomes "Lord of the Rings".
Is there a way to exclude this xml node from the xhtml rules?

View 6 Replies View Related

DOM In XHTML On IE6

Feb 27, 2007

Maybe you can answer a question for me: I'm reading the preview for XML web development (sitepoint book) and it clearly shows IE rendering XML (the author states IE5 and above); does that mean that IE's problem with XHTML is CDATA and not XML universally? If that's true then IE could render an albeit gimped XHTML page which would explain why HTML 4.01 and XHTML are virtually synonymous in IE 6.

Is there a workaround for this in JavaScript, if the above is true?

View 5 Replies View Related

Getting Correct Xhtml From DIV

Dec 23, 2005

I'm facing the bug about the failure of innterHTML while
reading xhtml content inside a DIV, in fact it has passed as html
removing the closing of some nodes. Is there a way to read the content
of the div perfectly how it is in the page, kind of:

var obj = document.getElementById("myDIV");
var realContent = obj.toString();

View 22 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved