Javascript for different Browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rupak
    New Member
    • Jan 2008
    • 25

    Javascript for different Browser

    Hi!

    I have been using javascript in HTML Page to write some text in a div, by using document.write( ""); which work perfectly in IE Browser, but not in mozilla.

    Can you please tell me what code should i use so that work in all the Browser.
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by rupak
    Hi!

    I have been using javascript in HTML Page to write some text in a div, by using document.write( ""); which work perfectly in IE Browser, but not in mozilla.

    Can you please tell me what code should i use so that work in all the Browser.
    document.write( "") should work on all browsers.

    Show your code.

    Comment

    • rupak
      New Member
      • Jan 2008
      • 25

      #3
      The code i am putting is in DIV and when i wirte any thing in div it work in morzilla but text in document.write does not work in mozilla thus the div text is not diplayed in morzilla but visible in IE

      Code:
      <div id='div1' style="display:none;">
      <form name="tcol">
      <script type="text/javascript">
      xmlDoc=loadXMLDoc("PMA_Portfolio.xml");
      var x=xmlDoc.getElementsByTagName("units/unit"); 
      var y=xmlDoc.getElementsByTagName("leases/lease");
      
      x.item(0).setAttribute("ref","Unit");
      x.item(0).setAttribute("strung_address","Address");
      y.item(0).setAttribute("current_tenant_ref","Tenant");
      y.item(0).setAttribute("tenant_party_to_lease","Name");
      y.item(0).setAttribute("ref","Lease Ref.");
      y.item(0).setAttribute("term_start_date","Lease Start Date");
      y.item(0).setAttribute("term_end_date","Lease End Date");
      y.item(0).setAttribute("next_review_date","Next Review");
      y.item(0).setAttribute("lease_type_code","Lease");
      y.item(0).setAttribute("property_analysis_code","Unit Property");
      y.item(0).setAttribute("passing_rent","Passing Rent");
      
      document.write("<p><A HREF=javascript:void(0) onclick=selectAll()>Select All</A> | <A HREF=javascript:void(0) onclick=deselectAll()>Deselect All</A></p>");
      document.write("<input type='checkbox' name='coffee' id='col1' value='Unit' checked />");
      document.write(x[0].getAttribute('ref'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col2' value='Address' checked />");
      document.write(x[0].getAttribute('strung_address'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col3' value='Tenant' checked />");
      document.write(y[0].getAttribute('current_tenant_ref'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col4' value='Name' checked />");
      document.write(y[0].getAttribute('tenant_party_to_lease'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col5' value='Lease Ref.' checked />");
      document.write(y[0].getAttribute('ref'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col6' value='Lease Term' checked />");
      document.write("Lease Term" + "<br />");
      document.write("<input type='checkbox' name='coffee' id='col7' value='Lease Start Date' checked />");
      document.write(y[0].getAttribute('term_start_date'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col8' value='Lease End Date' checked />");
      document.write(y[0].getAttribute('term_end_date'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col9' value='Next Review' checked />");
      document.write(y[0].getAttribute('next_review_date'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col10' value='Lease' checked />");
      document.write(y[0].getAttribute('lease_type_code'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col11' value='Unit Property' checked />");
      document.write(y[0].getAttribute('property_analysis_code'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col12' value='Passing Rent' checked />");
      document.write(y[0].getAttribute('passing_rent'));
      document.write("<br />");
      document.write("<input type='checkbox' name='coffee' id='col13' value='Rateable Value' checked />");
      document.write("Rateable Value" + "<br />");
      document.write("<input type='checkbox' name='coffee' id='col14' value='Area' checked />");
      document.write("Area" + "<br />");
      document.write("<p class='bot'><input type='button' onclick='show()' value='Save'> <input type='button' onclick='cancel()' value='Cancel'></p>");
      </script>
      </form>
      </div>

      Comment

      • rupak
        New Member
        • Jan 2008
        • 25

        #4
        Actuall it is DOM code which is not working, so can you give the code for writing the DOM in mozilla.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          IE and W3C-compliant browsers treat whitespace between nodes differently - see this link.

          Comment

          • rupak
            New Member
            • Jan 2008
            • 25

            #6
            Originally posted by acoder
            IE and W3C-compliant browsers treat whitespace between nodes differently - see this link.

            I have gone to the link you provided, i tried it but it did't work out. It is due to DOM coding in mozilla.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Show the code for the XML file.

              Comment

              • rupak
                New Member
                • Jan 2008
                • 25

                #8
                Code:
                <property ref="1">
                <units>
                        <unit property_ref="1" ref="1" description="description" search_name="Tower House" address_line_1="TEMPORARY ID  Unit 1    -   Converted li" building_name="Tower House" road_number="25-32" road_name_1="Bloomsbury Street" road_name_2="" town="LONDON" county="" postcode="WC1B 3EE" manager_code="1" listed_building="N" status="L" time_stamp="2007-09-26T17:40:08.743" date_created="2007-09-26T17:40:08.743" user_created="PIE" our_file_reference="our_file_reference" ext_file_reference="ext_file_reference" number_postcode="" uri="-2145377861" block_address_1="Tower House" block_address_2="25-32 Bloomsbury Street" block_address_3="LONDON" block_address_4="" block_address_5="WC1B 3EE" block_address_6="UK" block_address_7="" block_address_8="" strung_address="25-32 Bloomsbury Street" main_use_class="A2" sub_use_class="sub_use_class" no_of_floors="0" tenure="tenure" vat_opted="N" via_tramps="N" occupational_status="Occupied" name="Tower House" whole_of_property="N" os_ref="" uprn="0" easting_northing="123456789012" country_code="UK" />
                      </units>
                <leases>
                        <lease ref="61001" property_ref="6100" unit_ref="1" term_start_date="2000-09-11T00:00:00" term_end_date="2010-09-10T00:00:00" upwards_only_review="Y" review_notice_required="Y" review_basis="" review_pattern="0" continue_after_review="Y" interest_on_late_review="Y" late_review_interest_rate="0.0000" late_review_interest_basis="Above base" time_of_essence_clause="N" outside_1954_act="N" lt_1987_act_applies="N" privity_applies="N" passing_rent="0.00" rent_in_advance="Y" vat_on_rent_applies="No" interest_on_late_rent="N" days_grace_on_late_rent="0" late_rent_interest_rate="0.0000" late_rent_interest_basis="(None)" annual_s_c="12000.00" s_c_charge_type_code="SCO" s_c_due_date_code="MOD" s_c_in_advance="Y" vat_on_s_c_applies="All" interest_on_late_s_c="N" days_grace_on_late_s_c="0" late_s_c_interest_rate="0.0000" late_s_c_interest_basis="(None)" our_file_reference="" ext_file_reference="" breach_status="None" landlord_party_to_lease="Enterprise Properties Limited" tenant_party_to_lease="Kendal Beresford Design Limited" assignment_permitted="" subletting_permitted="" alterations_permitted="" restrictive_covenants="" resp_for_int_repairs="" resp_for_ext_repairs="" resp_for_building_insurance="" resp_for_lor_insurance="" resp_for_pl_insurance="" resp_for_plate_glass_ins="" resp_for_rates="" time_stamp="2003-08-26T12:09:02.660" date_created="2003-08-26T00:00:00" user_created="ADMIN" uri="-2145678987" status="L" s_c_commence_date="2000-09-11T00:00:00" resp_for_int_decs="" int_decs_first_year="0" resp_for_ext_decs="" pre_expiry_review="" undated_option="" undated_option_notice="0" lease_term="" termination_status="Current" late_rent_int_from_due_date="" late_s_c_int_from_due_date="" via_tramps="N" residential_use="" scottish_lease="N" current_tenant_ref="1" current_tenancy_uri="-2145678986" regulated_tenancy="N" registered_rent_pa="0.00" s_c_lease_charge_uri="-2145678984" stay_open_clause="N/A" rent_vat_rate_code="S" s_c_vat_rate_code="S" guarantor=" " change_of_use_permitted="" annual_s_c_adjustable="Y" other_fixed_recoverables="Y" recoverables_vat_rate_code="S" turnover_rent="N" period_rent="0.00" period_s_c="3000.00" late_rent_max_interest_rate="0.0000" late_rent_min_interest_rate="0.0000" late_sc_max_interest_rate="0.0000" late_sc_min_interest_rate="0.0000" late_review_max_interest_rate="0.0000" late_review_min_interest_rate="0.0000" interest_on_late_others="N" days_grace_on_late_others="0" late_others_interest_rate="0.0000" late_others_interest_basis="Above base" late_others_int_from_due_date="" late_others_max_interest_rate="0.0000" late_others_min_interest_rate="0.0000" s_c_apportionment_cap_amount="0.00" default_currency_code="GBP" option_1_type_code="" option_2_type_code="" option_3_type_code="" option_4_type_code="" option_5_type_code="" option_1_by="" option_2_by="" option_3_by="" option_4_by="" option_5_by="" option_1_term="0" option_2_term="0" option_3_term="0" option_4_term="0" option_5_term="0" annual_base_rent_amount="0.00" period_base_rent_amount="0.00" annual_on_account_amount="0.00" period_on_account_amount="0.00" base_rent="N" on_account="N" on_account_type=" " act_2002_applies="N" inclusive_rent="N" />
                </leases>
                    </property>

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Check that x and y have got the correct element by checking the length. See here how yo access DOM nodes.

                  Comment

                  Working...