Results 1 to 6 of 6

Thread: on load for rookies

  1. #1
    Join Date
    Oct 2009

    on load for rookies

    I'm trying to learn Javascript. Honestly, I don't know how you guys do it. Anyway, I wanted a little alert box to open when the url is loaded. So I tried a few permutations:

    <script type="text/javscript">
    function init(){
    alert ("This boy is working");


    <script type="text/javscript">
    window.onload=function (){
    alert ("This boy is working");

    When I type document.Haskins.sku.focus() into the firebug console, it works, so I'm really at a loss here. If you have any suggestions, I'd appreciate it

    p.s. I have onload="" in my body tag. I'm trying to migrate to a better implementation

  2. #2
    Join Date
    Sep 2009

    Without your full HTML it's hard to tell what the exact error is, so I will give you a few of my best guesses.

    For my first guess, your P.S. is what may hold the key

    Your body tag's onload is probably overwriting your script tag's window.onload event.

    My next guess is that the DOM may not be ready by the time you try to focus. In other words, your document.Haskins.sku doesn't exist yet when you try to focus() on it.

    If this doesn't solve it, see if you can post your complete page including your HTML.

  3. #3
    Join Date
    Oct 2009
    This message board is like MrExcel, so I hope I'm doing the right thing with the code tag. I thought about the prior two suggestions. I put my script all the way at the bottom of the screen, after the formation of the form so that it would exist when it runs. I also deleted the onload="" portion of the body tag to see if that was the reason, and it didn't seem to be. Well, anyway, here's the entire code. It's obvious a lot of clean up work is necessary

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html><head><title>Administration - Catalog</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="http://www.scrapbookingsuppliesrus.com/templates/sbsru/styles/style.css"><link rel="stylesheet" href="http://www.scrapbookingsuppliesrus.com/templates/sbsru/styles/blog.css"> <script src="http://www.scrapbookingsuppliesrus.com/templates/sbsru/scripts/dojo.js" type="text/JavaScript"></script></head> <body bgcolor="#ffffff" link="#0000ff" vlink="#000099" alink="#ff0000"><table width=100%> <tr>  <td class=h1>Catalog</td>  <td align="right" class="topmenu">   <!-- Login Code -->  </td> </tr></table> <hr size="1" color="#366090" /> <p /><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr valign="top">  <td width="10%">    <!-- admin nav -->   <table width="100%" align="center" bgcolor="#4d99e5" cellpadding="1" cellspacing="0" border="0">    <tr>     <td>       <table width="100%" cellpadding="2" cellspacing="0" border="0">       <tr align="center">        <td nowrap="nowrap">		 Admin Navigation        </td>       </tr>       <tr bgcolor="#e5f6ff">        <td>		 <a href="http://www.scrapbookingsuppliesrus.com/?admin">Admin Home</a><br />  		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=account">Accounts</a><br /> 		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=blog">Blogs</a><br />		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=catalog">Catalog</a><br />   		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=events">Events</a><br />   		 <a href="http://www.scrapbookingsuppliesrus.com/admin/forum">Forums</a><br />  		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=links">Links</a><br /> 		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=catalog&layer=locations">Locations</a><br />		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=mailing">Mailing</a><br />		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=order">Order</a><br /> 		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=order&layer=promo">Promos</a><br /> 		 <a href="http://www.scrapbookingsuppliesrus.com/?admin=testimonials">Testimonials</a><br /> 		 		 <hr size="1" color="#366090" />		 <a href="http://www.scrapbookingsuppliesrus.com/">Home</a></li>        </td>       </tr>      </table>      </td>    </tr>   </table>     </td>   <td width="15" nowrap="nowrap">  </td>  <td width="100%"> 	<table width="100%" cellspacing="0" cellpadding="0">		<tr>			<td bgcolor="#ffffff">				&nbsp;			</td>									<td bgcolor="#efefef" align="center"><a href="http://www.scrapbookingsuppliesrus.com/?admin=catalog">Browse</a></td>						<td bgcolor="#ffffff">&nbsp;</td>												<td bgcolor="#efefef" align="center"><a href="http://www.scrapbookingsuppliesrus.com/?admin=catalog&layer=import_products">Import Products</a></td>						<td bgcolor="#ffffff">&nbsp;</td>												<td bgcolor="#efefef" align="center"><a href="http://www.scrapbookingsuppliesrus.com/?admin=catalog&layer=import_descriptions">Import Descriptions</a></td>						<td bgcolor="#ffffff">&nbsp;</td>												<td bgcolor="#efefef" align="center"><a href="http://www.scrapbookingsuppliesrus.com/?admin=catalog&layer=import_categories">Import Categories</a></td>						<td bgcolor="#ffffff">&nbsp;</td>												<td bgcolor="#efefef" align="center"><a href="http://www.scrapbookingsuppliesrus.com/?admin=catalog&layer=import_vendors">Import Vendors</a></td>						<td bgcolor="#ffffff">&nbsp;</td>												<td bgcolor="#4d99e5" align="center">feature_update</td>						<td bgcolor="#ffffff">&nbsp;</td>								</tr>		<tr bgcolor="#4d99e5">			<td colspan="13"></td>		</tr>	</table>	  <h3>Featured product updater for Vivian's feature spotlighting delight.</h3> <table width="538">			<tr>				<td width="25%" align="center">					SKU				</td>				<td width="50%" align="center">					Description				</td>				<td width="vendor" width="25" align="center">					Vendor				</td>			</tr>		 <!--I'm sure we can just use the variable as an array or a number without recasting-->					<tr>				<td align="left">					655350528973				</td>				<td align="left">					Bonnet Blooms Pinkle				</td>				<td align="left">					Prima Marketing				</td>			</tr>					<tr>				<td align="left">					718813429870				</td>				<td align="left">					Thickers Bewitched- Melon				</td>				<td align="left">					American Crafts Lc				</td>			</tr>					<tr>				<td align="left">					895707019451				</td>				<td align="left">					The Halloween Collection Letter Stickers				</td>				<td align="left">					Reminisce				</td>			</tr>					<tr>				<td align="left">					009710116087				</td>				<td align="left">					A Spring Tail				</td>				<td align="left">					House Mouse				</td>			</tr>					<tr>				<td align="left">					725718986803				</td>				<td align="left">					Fall Leaf				</td>				<td align="left">					Inkadinkado				</td>			</tr>					<tr>				<td align="left">					876042006818				</td>				<td align="left">					Stripe				</td>				<td align="left">					Three Bugs In A Rug				</td>			</tr>					<tr>				<td align="left">					759668102051				</td>				<td align="left">					Embrace Stickeroos				</td>				<td align="left">					Penny Black				</td>			</tr>					<tr>				<td align="left">					655350840631				</td>				<td align="left">					Alpha Sticker- Cream				</td>				<td align="left">					Prima Marketing				</td>			</tr>					<tr>				<td align="left">					643077625655				</td>				<td align="left">					A To Z- Alphabet Page Pad				</td>				<td align="left">					K & Company, Llc				</td>			</tr>				</table><hr /><form method="post" name="Haskins" action="http://www.scrapbookingsuppliesrus.com/?admin=catalog&layer=feature_update"><span id="test">sku: </span><input type="text" size="10" maxlength="40" name="sku"><br /><input type="submit" value="Submit" name="send"><input type="submit" value="Clear list" name="clear"></form><script type="text/javscript" language="Javascript"> window.onload=function(){alert ("This boy is working");document.Haskins.sku.focus();}</script> </td></tr></table> <p><hr size=1 color=#366090><div align=right class=normal><i>Admin Area</i></div></body></html>

  4. #4
    Join Date
    Oct 2009

    That Code tag is not the best

    I must not be using it right, or notepad ++ doesn't copy right. Here's the code in more readable form:

    <h3>Featured product updater for Vivian's feature spotlighting delight.</h3>

    <table width="538">
    <td width="25&#37;" align="center">
    <td width="50%" align="center">
    <td width="vendor" width="25" align="center">
    <? if ($features != 0) : ?> <!--I'm sure we can just use the variable as an array or a number without recasting-->
    <? foreach ($features as $feature) : ?>
    <td align="left">
    <?=$feature['sku'] ?>
    <td align="left">
    <?=$feature['name'] ?>
    <td align="left">
    <?=$feature['vendor'] ?>
    <? else :?>
    <td colspan="3">
    The table is empty
    <? endif ?>
    <hr />
    <form method="post" name="Haskins" action="<?=$full_url?>">
    <span id="test">sku: </span><input type="text" size="10" maxlength="40" name="sku"><br />
    <input type="submit" value="Submit" name="send">
    <input type="submit" value="Clear list" name="clear">
    <script type="text/javscript">
    function init(){
    alert ("This boy is working");
    Last edited by oaishm; 10-04-2009 at 03:06 PM. Reason: code tag doesn't copy well

  5. #5
    Join Date
    Oct 2009

    four days and 108 views later...

    Well, after beating my head against the wall for five days and reading books everywhere, I've figured out how to make an html page locally to test code in stead of uploading all the time. I've tried firebug, which is quite handy. I've even reduced it to the smallest item possible, but still can't seem to get it to work.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    <!-- saved from url=(0074)http://www.scrapbookingsuppliesrus.com/?admin=catalog&layer=feature_update -->
    <HTML><HEAD><TITLE>Administration - Catalog</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><LINK 
    <BODY >
          <FORM name=Haskins 
          method=post><SPAN id=test>sku: </SPAN><INPUT maxLength=40 size=10 
          name=sku><BR><INPUT type=submit value=Submit name=send> <INPUT type=submit value="Clear list" name=clear> </FORM>
    <SCRIPT type=text/javscript>
    alert ("This boy is working");
    But then, just as I was about to hit the submit reply button, I figured it out. As you can see from my earlier posts, I misspelled javascript in the tag. I can't believe it...

  6. #6
    Join Date
    Sep 2009
    lol happens to all of us sooner or later :-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11852 seconds
  • Memory Usage 2,915KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates