Results 1 to 5 of 5

Thread: Can not see javascript?

  1. #1
    Join Date
    May 2013
    Louisville KY

    Can not see javascript?

    I am new to javascript and am building my first website, after having the content of the website typed up and styled with html and css, I wanted to practice writing a simple javascript code to it. The purpose of the javascript is to repeat on all the pages the copyright information for my website. (the simplest of all codes I believe....) anyways, I post this code to my <div id="footer"> section.

    <script type="text/javascript"

    I also have the page linked to the external .js file. This files holds ...
    <script type="text/javascript">
    var copyright='blah blah blah';

    Now when ever i reload Firefox to view the change to make sure the code works, my footer section of the page that is supposed to hold the copyright is blank... Its almost as if the code worked.. But it isn't displaying, I checked the settings, and yes javascript is enable on my browser, I can go and visit javascript enabled websites and view everything just fine.
    Any ideas on why the code is not displaying my information?

  2. #2
    Join Date
    Dec 2005


    You can not use "document.write('anything')" after the page has been rendered.

    If you do, the page is reloaded.

    Use a <footer id="footerTag"></footer> in the body
    and then, just before the </body> tag place a script
    <script type="text/javascript">
    var copyright='blah blah blah';
    document.getElementById('footerTag').innerHTML = copyright;

  3. #3
    Join Date
    May 2013
    Louisville KY
    I'm afraid I do not understand. If I am correct <footer></footer> is html5, the webpage I am building I have a doctype of 4.01 transitional. What I am wanting to do is a repeating variable, I think. I read about it in a javascript tutorial. And from what it explained, you can make an external JS file with a var equaling to a string of text, having it be what ever you want. Then all you have to do is place document.write(var name) into where you want to display that text in your page. The tutorial mentioned nothing of the footer id and getelementByID that you mentioned. I want to do this because I have the copyright information at the bottom of every page, and if I want to change it in the future, I do not want to have to go to every page and change it, I want to be able to change that one JS file so that then, every page information is changed automatically.
    Thank you for the reply by the way. Do you think you could clarify a little more?

  4. #4
    Join Date
    Dec 2005


    So instead of the <footer> tag pair, use a <div> tag pair instead.

    Then create an external file named, for example, that contains your copyright information:
    var copyrightedby = 'tsidebottom10';
    Then consistently give an id= for each page you wish the footer to be displayed, as in:
    <!doctype stuff...>
    <title> Whatever </title>
    <script type="text/javascript" src="footerInfo.js"></script>
    <div id="footerTag"></div>
    <script type="text/javascript">
    window.onload = function() { document.getElementById('footerTag').innerHTML = copyrightedby; }

  5. #5
    Join Date
    Oct 2010
    Versailles, France
    In this case, it's possible to use document.write (the document is not closed).
    But you have at first to load the script which define the variable copyright (a HTML string).

    An example of simple script copyrigth.js (which update the year).
    // JavaScript Document
    var copyright="<p>&copy; "+new Date().getFullYear()+"</p>";
    Then, your script should be placed in the footer with something like this :

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="generator" content="PSPad editor, www.pspad.com">
    <!-- Load the script -->
    <script type="text/javascript" src='copyright.js'></script>
    <style type="text/css">
    #footer {font-size:small;text-align:center;}
    		<p>Good luck</p>
    	<div id="footer">
    <!-- Insert the variable copyright in the footer -->
    <script type="text/javascript">
    Last edited by 007Julien; 05-12-2013 at 06:11 AM.

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.11514 seconds
  • Memory Usage 2,883KB
  • 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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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 (71):
  • 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_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