Separating Behavior(js) From Structure(xhtml)
Sep 29, 2004
I was reading Peter-Paul Koch's article about how to separate javascript from the html and put it in another file:
http://www.digital-web.com/articles/...d_structure_2/
but I can't get it to work(IE6 and Firefox1.0 on windows). Here is my html file:
Code:
<!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"
xml:lang="en" lang="en">
<head>
<title>Web Design 1</title>
<meta name="author" content="Mr. Smith, I presume" />
<meta name="description" content="web" />
<script src="mouseovers.js" type="text/javascript"></script>
</head>
<body>
<div><img id="mouseover_effect" src="green_square.jpg" /></div>
</body>
</html>
and here is my mouseovers.js file:
Code:
function initializeMouseOvers(){
var images=document.getElementsByTagName("img");
var c=images.length;
for(var ii=0; ii < c; ii++){
images[ii].onMouseOver=mouseover;
}
}
function mouseover(){
this.src="red_square.jpg"
}
window.onload=initializeMouseOvers;
A green square displays, but I don't get any rollover effect--I'm trying to get the green square to switch to a red square.
View 4 Replies
ADVERTISEMENT
Nov 26, 2010
I'm using ajax like this (from the docs):
$.ajax({
url: 'ajax/test.php',
success: function(data) {
// do something with data
}
});
[Code]...
Does anyone have any idea how to get the html inside each #content or do I need to use a different approach altogether? What I basically want to do is to be able to print a lot of HTML in the file, and then in the "success" update different parts of the current page with parts from that HTML.
View 2 Replies
View Related
Nov 24, 2010
Something like this:
['level1key':['level2key:'value']]
That is the value itself is any object.
View 12 Replies
View Related
Jul 23, 2005
I've got a div, and it has an onMouseOver handler attached to it which makes a second div visible. The second div shares part of one side with the first, but not all.
The first div also has an onMouseOut handler which, you guessed it, makes the second div invisible.
However, if the user rolls out of the first div and into the second, I'd like to keep the second div visible. Any ideas how to accomplish this?
View 5 Replies
View Related
Jun 27, 2009
My question is regarding the behavior of Supersubs in IE6. It seems to adjust to the correct width, but, it applies the new width to all of
the parent UL's of the widest LI. In IE7 and FF the new width is only applied to the containing UL of the LI.
View 1 Replies
View Related
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
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
Jul 23, 2005
Can this be refined further to be more efficient?
function shout()
{
if (isNaN(document.form1.entry.value)==true) {
alert("please only enter numbers for an answer")}
else
{
alert("the new number is: "+(+document.form1.entry.value+5))}
}
also what would be the correct structure as to make the script more legible
to regular and proficient writers of JS?
View 7 Replies
View Related
Jul 23, 2005
I'm trying to develop a tree structure using javascript. The node values of
the tree are generating from a mysql table depending on login. The tree
structure contains 3 sub levels.
I developed static HTML tree using http://www.treeview.net. now i need to
generate this tree dynamically.
View 1 Replies
View Related
Jan 3, 2012
I have a nested listview in my app which creates table inside table at runtimei need to get value of td from second tables tr where i have row number of first tables tr?
<listview1>
View 6 Replies
View Related
Jul 30, 2010
Is it possible to change a document structure definitely using JQuery ? I used .html() but after refreshing the page the changes I've done disappeared and were replaced by the default contents
View 2 Replies
View Related
Jul 29, 2009
I am trying to do the following without html frames.
-Let's say i a html file which contains the structure of a calendar (table, rows, cells, etc)
-Have javascript load the contents of the html file into the page without frames and without disturbing the previous content.
So the advantage is that i would not have to use javascript to create the structure of the calendar but instead to load it so that javascript only have to fill the contents of the calendar.
View 9 Replies
View Related
Nov 6, 2011
So firstly this is likely not in the right place at all, as it's a bit OT but I figured it's the best place to ask. I have to document 4 different tests to my code; what structure should I take when doing this?
I was thinking:
* State the aim of the test
* State the inputs, and what I believe the output should be.
* State the actual output, and whether this positively or negatively affect my code.
View 1 Replies
View Related
Dec 16, 2010
Let me explain the scenario. I have a main html (e.g. main.html) page, which includes a link to inner.html page. Clicking this link will load the inner page, containing a tree structure. [URL] The loading method is such that only the body content from inner page is loaded to the main page, without refreshing the main page.I believe this method is called partial rendering of pages.
[Code]...
View 11 Replies
View Related
Jul 31, 2009
In my application, there is a view page to show the table of Attributes name as the header and its value filled by many people below. [code]...
View 3 Replies
View Related
Jul 23, 2005
Is there a way, besides writing another method, to make Date.setMonth() do something more useful than nothing when the month in question creates an invalid date? If I try
d=new Date();
d.setMonth( 1 );
today, I'd really like to get some kind of an error rather than silent failure.
View 5 Replies
View Related
Nov 30, 2005
I have a table that changes its cell (input text) colors when their contents
have changed (actually on keypress) and shows a couple of buttons
automatically, UDPATE and CANCEL. This works partially, though detecting
enter and escape doesn't seem to work, or parhaps calling the button click
events directly doesn't (see below).
In addition to getting the ENTER and ESC keypresses to fire their
appropriate button clicks, I need to be able to collect information on which
cells have changed, so on the page loading again I can read this
information, perhaps from a hidden field, to use to update a database
server-side.
<script language=javascript>
function GirdTextKeyPress(txtID, btnsContainerlID, btnUpdateID, btnCancelID)
{
var txt = document.getElementById(txtID);
txt.className = 'GridChanged'
var bc = document.getElementById(btnsContainerlID);
bc.style.display = 'inline'
var btnUpdate = document.getElementById(btnsContainerlID);
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancelBubble = true;
btnUpdate.click();
}
var btnCancel = document.getElementById(btnCancelID)
if (event.keyCode == 61)
{
event.returnValue=false;
event.cancelBubble = true;
btnCancel.click();
}
}
</script>
<style>
Input.Grid
{
border-style:none;
}
Input.GridChanged
{
background-Color:Yellow
}
</style>
View 1 Replies
View Related
Aug 3, 2006
Normally, a button like <input type="image"is also a submit button.
Is there any way to override that so that it has an onclick event but
does not submit the form?
For what I'm trying to do, I cannot use an <imgelement with onclick.
I have to use a form element (and I'd rather have an image than a
button)
View 3 Replies
View Related
Oct 29, 2006
I coudn't understand some behavior of RegExp.test function.
Example html code:
----------------
<html><head></head><body><script type="text/javascript">
var r = /^https?:///g;
document.write( [
r.test('http://a'),
r.test('http://b'),
r.test('http://c'),
r.test('http://d')
]);
</script></body></html>
---------------------
The page displays true, false, true, false. (in Opera, Firefox and IE)
This is strange because I expected it would display true, true, true,
true. There must be something I didn't know about the function
RegExp.test.
View 11 Replies
View Related
Jul 20, 2005
I used the following script to allow me to bring up a list of events
for a given year by simply hovering the mouse over the filename. As
follows --
<script Language="JavaScript">
function winopen1(){
msg1=open
("","WINDOW1","toolbar=no,location=no,directories=no,status=no,me nubar=no,scrollbars=no,resizable=no,copyhistory=no ,width=550,height=200");
msg1.location="1989H.htm"}
</Script>
Then....
<a href="1989H.htm" onMouseOver="winopen1();return true;"
onMouseOut="msg1.close();return true;">1989</a></font></td>
This is one example .... this is repeated about 20 times in the
program, one for each year of our history...
It works fine ... but not on all the browsers in our office. Most work
fine ... others (all IE) work fine on some dates; other dates, when
you hover, flash a blank page repeatedly until you move the mouse
away; almost as though it is looping ...
I notice that "about:blank" flashes briefly before the called page
comes up ... but that appears to be normal.... I have checked and
rechecked all coding, all brackets and semi-colons ... and it works
perfectly -- for me and for a few others.
View 1 Replies
View Related
Jul 20, 2005
I expect to see "foo" for the 2nd alert. Instead, the value of select is
cleared. Am I missing something?
<html>
<head><title>Foo</title>
<script language="javascript">
<!--
function foo()
{
alert('Before change: ' + document.control.titleFont.value);
document.control.titleFont.value = 'foo'
alert('After change: ' + document.control.titleFont.value);
}
-->
</script>
</head>
<body>
<form name="control" method="POST">
<select name="titleFont">
<option value="sans-serif">Arial</option>
<option value="serif">Times</option>
</select>
<input type="submit" name="control" value="Submit" onclick="return
foo()"/>
</form>
</body>
</html>
View 1 Replies
View Related
Jul 20, 2005
I've been working with a page that should act as a 'jump page' before
loading a PDF and when I use the location.replace function to replace
the jump page with the resulting PDF, both the jump page and the pdf
show up into the browser history (in IE only) leading to the dreaded
back-button loop. Code:
View 1 Replies
View Related
Jul 20, 2005
I want to call a JS function when Enter is pressed inside the form, and when the submit button is clicked I want to submit the form. Any simple way for doing this?
View 1 Replies
View Related
Mar 11, 2003
i'm sure its been thought of before and i'm sure this is just gunna piss off the people who like to tab through their pages, but i just made a little behavior component file that stops any links from gaining focus on your page.
put this is the style section of your page.
<style type="text/css">
a { behavior: url("hidefocus.htc"); }
</style>
then put the attached file in the same dir. (hidefocus.htc) this is all it is
<public:component>
<public:attach event="onfocus" handler="blurry" />
<script>
function blurry() {
element.blur();
}
</script>
</public:component>
Note: since this behavior is stored in an external file, sometimes one instance of link focus can occur before the htc file can be loaded. if anyone has any tips on fixing that i'd like to hear'em.
View 16 Replies
View Related
Feb 6, 2009
I have a drop down menu on my page, works. Then I went to add another ddm, doesn't work when on page, but works independently . DW creates a file called mm_menu.js. I am sure the problem is here, but I don't know what to change. Might anyone here know what I am talking about/had this prob before?
View 1 Replies
View Related
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