HI there,
I was again watching a jquery/ajax tutorial and in the video http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-day-10/ they show how to use a return:false;
to determine whether a scrip will execute (javascript on) or will go to a separate page if the javascript is off.
Basically I have 2 pages test.htm and new_file.htm. The former will get the list from the latter page and load onto the test.htm. This is done via jquery. the trainer uses as a trigger a link on the test.htm page which originally goes nowhere, then he changes that to point to new-file.htm and he says and shows that if we add
return:false;
to the jquery script if you click on "show list" when javascript is enabled it works fine, when instead javascript is disabled when the link is clicked on it goes to the new_file.htm. I tried that in here http://antobbo.webspace.virginmedia.com/various_tests/2011_10_29_ajax/test.htm and obviously it doesn't work, whether javascript is on or off it still goes to the new_file.htm page so I was wondering if anybody can shed some light on it at all. Let's have a look at the code, it might be easier to understand rather than me attempting to explain:
test page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('a').click(function(){
$('<div id="info"/>').load('new_file.htm #movies',function(){
$(this).hide()
.appendTo('#container')
.slideDown(1000);
});
return:false;
});
});
</script>
</head>
<body>
<div id="container">
<h1>My movies</h1>
</div>
<a href="new_file.htm">Show list</a>
</body>
</html>
page where the list is copied from:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>another test page</title>
</head>
<body>
<ul id="movies">
<li>element 1</li>
<li>element 2</li>
<li>element 3</li>
</ul>
</body>
</html>