The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Another Javascript Thread

RendRend Registered User regular
edited June 2009 in Help / Advice Forum
Hey guys, I'm back with more questions about my favorite programming language that I don't really know how to use. On the bright side, I recently bought a book to teach myself, so hopefully next time I'll be on the opposite side of a thread like this.

So here's the deal.

I have some specific js functions on a page. I have them copied on 3 pages, exactly. One is a page I copied from (copy-from), one is a page I copied to (copy-to), and one is a page which I also copied to, but on which it is the only thing there (ie my test page which i did in notepad and just has minimum tags to make it an html document) (copy-test).

Copy-from works in firefox and IE. Copy-to works in firefox but not in IE. I am relatively confident that it's because some scripts are either not running, or are not running correctly, and my suspicion is that they are not running at all, since I'm getting visuals that look a lot like when they weren't running in firefox, before the script was complete.

Here's the catch.

Copy-test works in firefox, and works in IE as long as I right-click "allow blocked content" at the top of my IE when I do it. That bar does not appear when I try to run copy-to in IE, just when I run copy-test.

I'm not sure if it's relevant, but when I open copy-to in IE, it never finishes loading. Did not have that problem with copy-from or copy-test.

Any insight here?

Need more information? This is confounding. I really don't know how to differentiate between IE and FF in javascript, so I don't even really know what I'm looking for here.

Rend on

Posts

  • flatlinegraphicsflatlinegraphics Registered User regular
    edited June 2009
    do you have an example online somewhere?

    if you are trying to move variables or content from page to page, I would suggest that there may be better ways to do it than js.

    and IE may be blocking what it considers to be cross site scripting, which is generally a Good Thing. Those are some common infection and id theft vectors. Otherwise, it may be some DOM errors. No idea without an example.

    alternately, look into using jQuery or another library and some AJAX type trickery (specifically innnerHTML).

    flatlinegraphics on
  • RendRend Registered User regular
    edited June 2009
    do you have an example online somewhere?

    if you are trying to move variables or content from page to page, I would suggest that there may be better ways to do it than js.

    and IE may be blocking what it considers to be cross site scripting, which is generally a Good Thing. Those are some common infection and id theft vectors. Otherwise, it may be some DOM errors. No idea without an example.

    alternately, look into using jQuery or another library and some AJAX type trickery (specifically innnerHTML).

    Actually it's jquery and jcarousel I'm working with, and yahoo api extensions. I'm trying to load content dynamically into the carousel, but this is all happening regardless of the dynamic content. Right now copy-to looks like copy-from did before I declared the carousel correctly, but I'm pretty certain that it's correctly declared.

    It could very well be trying to block cross site scripting. What can you tell me of that? I don't think the yahoo api includes are being blocked, just since copy-from works, and I can't find the name of the site or directory or anything path-wise in the includes. They're all on my harddrive, by the way, so they're running from localmachine.

    [EDIT] Not trying to pass variables, just trying to get these scripts to work independently on each page.

    Rend on
  • flatlinegraphicsflatlinegraphics Registered User regular
    edited June 2009
    oh, reading is fundamental. you copied the script from page to page, not a variable from page to page.
    are you declaring the scripts at the top of each page? or linking them to an external .js file?
    moving the scripts to an external file and using
    <script src="path/to/my.js" type="text/javascript"></script>
    this will make sure everything is actually the same.

    also, make sure that everything has it's own id. might want to change them from page to page, to make sure.

    cross site scripting is a technique by which you run a script to try and post content to pages in someone's history, specifically banking sites or any popular login required site. usually posted as an img tag with the source being a javascript file posting to their history. it may be detecting that you are trying to access a separate domain from localhost and flagging it as a hijack attempt. no idea. without having it up in public somewhere its hard to trouble shoot.

    maybe one of the other hardcore JS people will stop in. I'm a css ninja by trade.

    flatlinegraphics on
  • RendRend Registered User regular
    edited June 2009
    yeah I've run through my declarations, they're a mix between scripting inline and calling outside .js, and I'm pretty sure everything is properly declared and assigned. In any case, like I said, I used copy paste and then just made sure all the files I required got ported over from the directory of copy-from to the directory of copy-to, which each have the same names.

    Also, the id's for the stuff is going to be the same, but that's a parameter I have to work with. Still, shouldn't matter since I'm not trying to pass anything page-to-page, and the id's should be unique page-wide.

    I wish I could put an example up online to look at but almost all I do is confidential since this is a work-related issue. Thanks anyway for your attempts, but to go further, is there anything other than putting a page up online that I could do to help everyone help me?

    Rend on
  • Vrtra TheoryVrtra Theory Registered User regular
    edited June 2009
    Are you declaring the document type at top-of-page? If not, IE7 (assuming you're using IE7) may be in quirks mode, which could be affecting your result.

    (Basically, make sure the first line in your HTML is one of the valid !DOCTYPE tags.)


    I'm going to go ahead and guess that this is your situation:

    1) You worked out all your content and Javascript for the complicated feature you're working on and called it "copy-from".

    2) You then took the old, existing page (or designer's template, or whatever), tried copying the scripts and content into it, and it didn't work no matter what you tried. (This is "copy-to".)

    3) To begin troubleshooting the problem, you tried creating a brand new blank page and copied the scripts over, and it still doesn't work right. ("copy-test".)


    Assuming that situation, my #1 advice is to get every single line of Javascript out of your page and into external js files. That would mean taking the working copy-from, loading it up in IE, and then moving the various scripts out while making sure that it still works in IE.

    After I did that, I would then begin adding to that page the various pieces of the old site (or designer's template, etc.), reloading it in IE after each discrete step. As soon as it stops working, you'll know what piece of the site is giving you a problem.

    That's not much of an answer, but as you know, without seeing it it's tough to troubleshoot it :).

    Vrtra Theory on
    Are you a Software Engineer living in Seattle? HBO is hiring, message me.
  • RendRend Registered User regular
    edited June 2009
    I seem to have fixed it, though I'm not sure why.

    I had a function that is supposed to execute when the page loads, which declares the variables I need for the functionality I'm looking for. For some reason, in copy-to it's not executing, because I took the declaration outside of the { } and put it at the very end of the <body>, and now it works.

    So something was stopping the yahoo.util pageload function from recognizing when it should execute.

    I looked at it, and the doctype line is there, so I'm still a little stumped as to why this happened. But, that's why I am teaching myself how to use this confounded stuff now, I suppose. Anyway, thanks a lot for your help, guys, you actually did help me get myself on track here.

    Rend on
Sign In or Register to comment.