Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    20
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Checking file exists or not using javascript??

    i want to check that if a path to a file is given and we want to check that the file is present there or not in that directory..??

    Below is my html snippet in which i am passing my path as argument in javascript function written in html header section..

    Code:
    <li><a onclick="db_mcmm('../report_data_fe_nldm_completeness/DB_existence_PVT_report.html');"><h3><u>DB NLDM MCMM</u></h3></a></li>
    Javascript function written in header section is as follows :

    Code:
    <script ="text/javascript">
      
       function db_mcmm(value) {
         var mcmm_file=document.getElementById('content');
         mcmm_file.innerHTML= "<iframe src=" + value + " width=\"79%\" height=\"600px\"></iframe>";
       }
      </script>
    Is it possible to check if the file is present in that specified path directory...

  • #2
    New Coder
    Join Date
    Sep 2012
    Posts
    22
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Can you share me your "id=content" code in html?

  • #3
    New Coder
    Join Date
    Jul 2012
    Posts
    20
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by shyagrawal View Post
    Can you share me your "id=content" code in html?
    Code:
     <div id="content"></div>
    its only a div in which i am appending my output... If u want whole html page ican give u that also for bettr idea...

    Code:
    <!DOCTYPE html>
    <html>
      <head>
      <script src="Data.js"></script>
      <script src="Report_functions.js"></script>
      <script src="table.js"></script>
      <link rel='stylesheet' type='text/css' href='table.css'>
      <script ="text/javascript">
      
       function update_help_file(value) {
        var help_file=document.getElementById('help');
        help_file.innerHTML="<iframe src=" + value + " width=\"79%\"></iframe>";
       }
    
       function default_help_file(value) {
        var default_file=document.getElementById('content');
        default_file.innerHTML="<iframe src=" + value + " width=\"79%\"></iframe>";
       }
    
       function db_mcmm(value) {
    
         var mcmm_file=document.getElementById('content');
         mcmm_file.innerHTML= "<iframe src=" + value + " width=\"79%\" height=\"600px\"></iframe>";
      }
     </script>
        
      </head>
      <body>
        <div id="toc" class="toc">
        <h1>Data Checks</h1>
        <h2>Existence Checks</h2>
        <ul>
          <li><a onclick="update_help_file('../../../scripts_block/html/help_existence.html'); default_help_file('../../../scripts_block/html/help_default.html');  lib(FRS_existance_lib); "><h3><u>Library Data</u></h3></a> </li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_existence.html'); default_help_file('../../../scripts_block/html/help_default.html'); tech(FRS_existance_tech);"><h3><u>Technology Data</u></h3></a></li>
        </ul>
        
        <h2>Syntax Checks</h2>
        <ul>
          <li><a onclick="update_help_file('../../../scripts_block/html/help_syntax.html'); default_help_file('../../../scripts_block/html/help_default.html'); lib(FRS_syntax_lib); "><h3><u>Library Data</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_syntax.html'); default_help_file('../../../scripts_block/html/help_default.html'); tech(FRS_syntax_tech);  "><h3><u>Technology Data</u></h3></a></li>
        </ul>
        
        <h2>POK Checks</h2>
        <ul>
          <li><a onclick="update_help_file('../../../scripts_block/html/help_pok_pm_cells_check.html'); default_help_file('../../../scripts_block/html/help_default.html'); html_table(FRS_ccs);"><h3><u>CCS POK Cells Summary</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_pok_pm_cells_check.html'); default_help_file('../../../scripts_block/html/help_default.html'); html_table(FRS_nldm);"><h3><u>NLDM POK Cells Summary</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_pok_cell_power_check.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_cell_power_check);"><h3><u>Cell Power</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_pok_LS_cell_pin_functionality_check.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_LS_cell_pin_funtionality_check);"><h3><u>LS Cell Pin Functionality</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_pok_LS_cell_voltage_range_check.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_LS_cell_voltage_range_check);"><h3><u>LS Cell Voltage Range</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_pok_power_down_function_attribute_check.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_pok_power_down_funtion_attribute_check);"><h3><u>Power Down Funtion Attribute</u></h3></a></li>
        </ul>
    
        <h2>Consistency Check</h2>
        <ul>
          <li><a onclick="update_help_file('../../../scripts_block/html/help_check_default_threshold_voltage_group_attribute.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_default_threshold_voltage);"><h3><u>Default Threshold Voltage Group</u></h3></a></li>
    
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_db_mcmm.html'); default_help_file('../../../scripts_block/html/help_default.html'); db_mcmm('../report_data_fe_nldm_completeness/DB_existence_PVT_report.html');"><h3><u>DB NLDM MCMM</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_db_mcmm.html'); default_help_file('../../../scripts_block/html/help_default.html'); db_mcmm('../report_data_fe_ccs_completeness/DB_existence_PVT_report.html');"><h3><u>DB CCS MCMM</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_check_library_features_db.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_library_features_db);"><h3><u>Library Features DB</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_across_db.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_across_db);"><h3><u>Across DB</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_db_filename.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_db_filename);"><h3><u>DB Filename</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_db_mw.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_db_mw);"><h3><u>DB MW</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_db_verilog.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_db_verilog);"><h3><u>DB Verilog</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_db_voltage_range.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table(FRS_db_voltage_range);"><h3><u>DB Voltage Range</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_completeness_ant_rules_metal.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table1(FRS_ant_rules_metal);"><h3><u>Ant Rules Metal</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_cel_fram_mw.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table1(FRS_cell_frame_mw);"><h3><u>Cell Frame MW</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_lvs_mw_reflist.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table1(FRS_lvs_mw_reflist);"><h3><u>LVS MW Reflist</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_metal_direction.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table1(FRS_metal_direction);"><h3><u>Metal Direction</u></h3></a></li>
          
          <li><a onclick="update_help_file('../../../scripts_block/html/help_consistency_mw.html'); default_help_file('../../../scripts_block/html/help_default.html'); pok_html_table1(FRS_mw);"><h3><u> Consistency MW</u></h3></a></li>
    
    
        </ul>
          
        <a onclick="update_help_file('../../../scripts_block/html/help_physical_verification_check.html'); pv_check(FRS_pv_check);"><h2>Physical Verification Check</h2></a>
          
          
      </div>
      <div id="help"></div>
      <div id="content"></div>
      </body>
    </html>

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Hi,

    First, take the onclick handlers out of your HTML. It's bad practice.

    Update your links to look like:

    Code:
    <a class="load_inline" href="../report_data_fe_nldm_completeness/DB_existence_PVT_report.html"><h3><u>DB NLDM MCMM</u></h3></a>
    (ie: give them a class of "load_inline", and put the file that you want loaded in the href attribute).

    Now put this in your document <head>

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type="text/javascript">
    $(function(){
    	$('.load_inline').on('click', function(event){
    		event.preventDefault();
    		$('#content').load( $(this).attr('href'), function(responseText, textStatus, XMLHttpRequest){
    			if ('success' != textStatus) {
    				$("#content").html("Sorry, an error occurred");
    			}
    		});
    	});
    });
    </script>


  •  

    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
    •