473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Javascript for different Browser

25
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.
Feb 27 '08 #1
8 1624
hsriat
1,654 Expert 1GB
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.
Feb 27 '08 #2
rupak
25
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

Expand|Select|Wrap|Line Numbers
  1. <div id='div1' style="display:none;">
  2. <form name="tcol">
  3. <script type="text/javascript">
  4. xmlDoc=loadXMLDoc("PMA_Portfolio.xml");
  5. var x=xmlDoc.getElementsByTagName("units/unit"); 
  6. var y=xmlDoc.getElementsByTagName("leases/lease");
  7.  
  8. x.item(0).setAttribute("ref","Unit");
  9. x.item(0).setAttribute("strung_address","Address");
  10. y.item(0).setAttribute("current_tenant_ref","Tenant");
  11. y.item(0).setAttribute("tenant_party_to_lease","Name");
  12. y.item(0).setAttribute("ref","Lease Ref.");
  13. y.item(0).setAttribute("term_start_date","Lease Start Date");
  14. y.item(0).setAttribute("term_end_date","Lease End Date");
  15. y.item(0).setAttribute("next_review_date","Next Review");
  16. y.item(0).setAttribute("lease_type_code","Lease");
  17. y.item(0).setAttribute("property_analysis_code","Unit Property");
  18. y.item(0).setAttribute("passing_rent","Passing Rent");
  19.  
  20. document.write("<p><A HREF=javascript:void(0) onclick=selectAll()>Select All</A> | <A HREF=javascript:void(0) onclick=deselectAll()>Deselect All</A></p>");
  21. document.write("<input type='checkbox' name='coffee' id='col1' value='Unit' checked />");
  22. document.write(x[0].getAttribute('ref'));
  23. document.write("<br />");
  24. document.write("<input type='checkbox' name='coffee' id='col2' value='Address' checked />");
  25. document.write(x[0].getAttribute('strung_address'));
  26. document.write("<br />");
  27. document.write("<input type='checkbox' name='coffee' id='col3' value='Tenant' checked />");
  28. document.write(y[0].getAttribute('current_tenant_ref'));
  29. document.write("<br />");
  30. document.write("<input type='checkbox' name='coffee' id='col4' value='Name' checked />");
  31. document.write(y[0].getAttribute('tenant_party_to_lease'));
  32. document.write("<br />");
  33. document.write("<input type='checkbox' name='coffee' id='col5' value='Lease Ref.' checked />");
  34. document.write(y[0].getAttribute('ref'));
  35. document.write("<br />");
  36. document.write("<input type='checkbox' name='coffee' id='col6' value='Lease Term' checked />");
  37. document.write("Lease Term" + "<br />");
  38. document.write("<input type='checkbox' name='coffee' id='col7' value='Lease Start Date' checked />");
  39. document.write(y[0].getAttribute('term_start_date'));
  40. document.write("<br />");
  41. document.write("<input type='checkbox' name='coffee' id='col8' value='Lease End Date' checked />");
  42. document.write(y[0].getAttribute('term_end_date'));
  43. document.write("<br />");
  44. document.write("<input type='checkbox' name='coffee' id='col9' value='Next Review' checked />");
  45. document.write(y[0].getAttribute('next_review_date'));
  46. document.write("<br />");
  47. document.write("<input type='checkbox' name='coffee' id='col10' value='Lease' checked />");
  48. document.write(y[0].getAttribute('lease_type_code'));
  49. document.write("<br />");
  50. document.write("<input type='checkbox' name='coffee' id='col11' value='Unit Property' checked />");
  51. document.write(y[0].getAttribute('property_analysis_code'));
  52. document.write("<br />");
  53. document.write("<input type='checkbox' name='coffee' id='col12' value='Passing Rent' checked />");
  54. document.write(y[0].getAttribute('passing_rent'));
  55. document.write("<br />");
  56. document.write("<input type='checkbox' name='coffee' id='col13' value='Rateable Value' checked />");
  57. document.write("Rateable Value" + "<br />");
  58. document.write("<input type='checkbox' name='coffee' id='col14' value='Area' checked />");
  59. document.write("Area" + "<br />");
  60. document.write("<p class='bot'><input type='button' onclick='show()' value='Save'> <input type='button' onclick='cancel()' value='Cancel'></p>");
  61. </script>
  62. </form>
  63. </div>
Feb 28 '08 #3
rupak
25
Actuall it is DOM code which is not working, so can you give the code for writing the DOM in mozilla.
Feb 28 '08 #4
acoder
16,027 Expert Mod 8TB
IE and W3C-compliant browsers treat whitespace between nodes differently - see this link.
Feb 28 '08 #5
rupak
25
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.
Feb 28 '08 #6
acoder
16,027 Expert Mod 8TB
Show the code for the XML file.
Feb 28 '08 #7
rupak
25
Expand|Select|Wrap|Line Numbers
  1. <property ref="1">
  2. <units>
  3.         <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" />
  4.       </units>
  5. <leases>
  6.         <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" />
  7. </leases>
  8.     </property>
Mar 3 '08 #8
acoder
16,027 Expert Mod 8TB
Check that x and y have got the correct element by checking the length. See here how yo access DOM nodes.
Mar 3 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: El Durango | last post by:
Hi I have a simple CGI program that takes data from a data source and posts it as XML format on the browser, I have tested my program on IE and Mozilla and they behave differently. Sometimes XML...
5
by: wylbur37 | last post by:
How do you find out what version of JavaScript your browser supports? Is there a JavaScript function that will tell you? __________________________________ Do you Yahoo!? Find out what made...
1
by: coofucoo | last post by:
We need to draw a curve with javascript in different browser, like IE5+, firefox1+, mozilla1.2+. Is there any existed javascript framework or library we can use? Thank for your help!
2
by: KC | last post by:
Hi, Every JavaScript executive context has a top-level window and we can use window.open() to open another window ... Does this related to Windows created by click on "File"->"New Window" or...
3
by: Jukka K. Korpela | last post by:
Some time ago in this group, someone suggested that we should develop a "different" user style sheet to demonstrate what a user style sheet or a browser style sheet _could_ do. I guess the idea was...
8
by: wpelgrum | last post by:
When I open a webpage with javascript my browser (both IE6 and FF2.0.0.3) freezes anywhere from seconds to more than a minute. During that period, the browser is frozen and windows (XP-SP2) is very...
1
by: sreedhardasi | last post by:
Hi, I would like to call a javascript function when user clicks on browser's close button. Here is the scenario. 1. User clicks browser close button. 2. User will be displayed a popup or a...
3
by: goldenv | last post by:
Hi all, I have worked an open source javascript + html page that has the potential to replace your existing browser home page. If you are interested in trying it out, or learning more about it, it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.