SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE Problem: variables declared in separate <script> block to js file, "undefined"?

    PHP Code:
    <script type="text/javascript">
        var bLoggedIn = <?=$bLoggedIn "true" "false"?>;
        var sRole = "<?=$sRole?>";
        var sAppView = "";
        var searchParams = $H({ dateFrom: 'ship', }).toQueryString();
    </script>
    <script type="text/javascript" src="javascripts/myscript.js"> </script>
    SO when I load the page in IE it complains that bLoggedIn is undefined in a function in "myscript.js".
    How do I get IE to be aware of the variables defined in the separate script block?

    Thanks

    Edit: After reading around some more pages it appears to be a scope issue, but also from what I've read I've done everything to make it global, so maybe its a timing issue?? Using Prototype JS library the function that is called that throws up the "bLoggedIn is undefined" is called from Event.observe(window, 'load', init); - So I have all my chickens lined up so to speak. The variables are Global, everything is suppose to be loaded due to waiting for the onLoad event to fire. I might just call an external file that is itself a php file.... bit crap. Surely this problem isn't new and someone can point me in the right direction as to what is going on here :)

    SORETED: Looks like there is an issue this line "var searchParams = $H({ dateFrom: 'ship', }).toQueryString();" so I've just made it a empty string for now....

    I'm really targeting FF as this is an Intranet app, but would like to know wtf is going on with IE here... The app will eventually work in IE6/7 but in terms of right now it only needs to work in FF as that's what I use :) (have a custom portable FF (stripped everything out that I could) installed (read 7-zip sfx'd, then extracted to c:\Firefox w/ a shortcut on the desktop) on the pc's of other people as they are all IE users, non computer literate types that I just say, "click that shortcut on the desktop and click that, there is the app")
    Last edited by SoreGums; Jun 19, 2007 at 22:16.

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That extra comma after the 'ship' will casuse problems. Good work finding the problem.
    Hello World

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX View Post
    That extra comma after the 'ship' will casuse problems. Good work finding the problem.
    Ahh Brilliant, so couldn't see that till you pointed it out.... Thanks :)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •