Jump to content

Webworldx

Members
  • Posts

    347
  • Joined

  • Last visited

Posts posted by Webworldx

  1. Couldn't you just put what's in the function (window.location.href="") in the actual onlclick thingy? :) Besides, I have 5 images maps and it didn't work right when I hooked all 5 up the same way I did the first one... :):):blink:
    You could - i'm not much of a fan of inline javascript like that if I can help it though =)
    <area shape="rect" coords="0,0,100,100" alt="Other Page" onclick="gotoPage('My Other Page.htm')" onmouseover="window.status='Click here to go to my other page'" style="cursor:link">

    Isn't it cursor: pointer ?
  2. I thought i'd add this: http://blogs.ifcode.com/webworldx/114/my-online-time/It's part-discussion, part-rant but there's some good points in there I think. I switched to Firefox last week in one of those "don't use IE and see what the competition is like" periods. Overall, i'm impressed with the speed and some of the features of Firefox Beta 2, but to be honest - there's not an overall jump in number of features between it and IE7 w/ Maxthon.

  3. It would be \" not /" :)If you're wanting to add that much content though, there is an easier way - drop it all onto the page completely, and hide it.

    .... select stuff here...<div id='home_content' style='display: none;'>   ... all the home content HTML in here, form etc etc</div><div id='about_content' style='display: none;'>  .... all the about content in here...</div>

    Then you just need to dodocument.getElementById('about_content').style.display="block";and it'll add it to the page. There's downsides - obviously all the content gets loaded onto the page every time it's accessed rather than progressively as JS would do - but if you can live with that - it might be quicker - and certainly cleaner :)

  4. <script type='text/javascript'>/*Random Independent NumbersCreated by Webworldx - w3Schools*/var highest_number = 10;var num_you_want = 5;var current_list = new Array();function draw_number(){	var selected_num = Math.ceil( Math.random() * highest_number);	for(j=0;j<current_list.length;j++){		if(selected_num == current_list[j]){			//Number already selected			return draw_number();		}	}	return selected_num;}function go_get_numbers(){	if(num_you_want > highest_number){		// You can't ask for more numbers than it's possible to get		return false;		}		for(i=0;i<num_you_want;i++){		current_list[current_list.length++] = draw_number();	}	return current_list;}var independent_numbers = go_get_numbers();alert(independent_numbers);</script>

  5. An interesting one! I'm sure someone will come up with a better solution (RegExp test with a while loop that I couldn't quite manage...), but here's my idea:

    <div id='the_text'>hello<br>dog<br />cat<br></div><script type='text/javascript'>var my_div = document.getElementById('the_text')var my_div_matches = my_div.innerHTML.split(/<br(.*?)>/i);for(i=0;i<my_div_matches.length;i++){	my_div.innerHTML = my_div.innerHTML.replace( my_div_matches[i] , "{1}" + my_div_matches[i] );}</script>

    Obviously it's on a small scale - so don't know how it'll transfer into what you're doing.

  6. <html><head><script type="text/javascript"><!--function change_pages(val){	if(val == ""){		document.getElementById('updater').innerHTML = "Please select which page you would like to edit";	} else {		document.getElementById('updater').innerHTML = "You selected " + val + ".";	}}//--></script></head><body><form><select name="pages" onchange="change_pages(this.value);"><option value=""></option><option value="home">Home</option><option value="about">About</option><option value="services">Services</option><option value="media credits">Media Credits</option><option value="testimonials">Testimonials</option><option value="links">Links</option></select></form><div><h2 id="updater"></h2></div></body></html>

    How's that? I think it basically emulates what you were trying to do. I put the id on the h2 to save a bit of code, but obviously you can put it back on the <div> and add it to the innerHTML in the javascript.:)

  7. or a while loop and keep bringing up the prompt box until they enter a number or exit out :)I've never used Number() to be honest, although not sure why - I just prefer the Math.floor() and parseInt() functions

  8. Doesn't seem to be anything wrong with that snippet... i've extended it a bit just to show it does work without the alert:

    <script>function getstatus(){	return "playing";}var status = getstatus();if ( status != "playing"){	alert('not playing');} else{	alert('is playing');}</script>

    Runs fine and displays the correct result.

  9. I much prefer a short RegExp validation like:

    var theString = 'test@email.com';function testEmail(str){  var reg_email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;  return reg_email.test(str);}var is_valid_email = testEmail(theString);alert(is_valid_email);

    Obviously it doesn't test correct domain extensions etc, but it's not a bad starting point. I don't really see the point in smartwebby's multiple indexOf statements, but maybe it's just me. :)

  10. Hi there LaLaLa.Most browsers won't display the status text on image maps if you've got a href attribute, so the workaround is to use onclick.

    <html><body><script type='text/javascript'>function gotoPage(page){	window.location.href = page;}</script><map id="links" name="links"><area shape="rect" coords="0,0,100,100" alt="Other Page" onclick="gotoPage('My Other Page.htm')" onmouseover="window.status='Click here to go to my other page'"></map><img src="Some big picture that I have.jpg" usemap="#links"></body></html>

×
×
  • Create New...