简体   繁体   中英

Why is my onload function not working?

Here is the index file to my web application located in the host_name directory.

<?php

  include 'b2.php'; 

  session::start();

  if(session::is_active())
    {
    include 'b2e.htm';
    }
  else
    {
    include 'b1e.htm';
    }
?>

I call

public static function reload()
    {
    $uri = 'http://';
    $uri .= $_SERVER['HTTP_HOST'];
    header('Location: '.$uri.'/host_name');
    }

to reload the page b2e.htm after a use logs in.

This works.

However, the onload functions are not called in my.js file - here. There is only one.js file included in both b2e.htm and b1e.htm.

window.onload=n;
function n()
  {
  var a;
  if(a=document.getElementById('f0d'))
    {
    a.onclick=i0;
    document.getElementById('f1e').onclick=i1;
    }
  else
    {
    document.getElementById('f2a').onclick=i2;
    document.body.style.backgroundColor="#eeeeee"; 
    }
  }

basically the statements in the else should execute but the are not.

A header() call will not initiate the onload function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM