www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 10-31-2009, 03:48 PM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    Question Browser blocks Javascript?

    Hello. I just wrote a website for a friend - very basic since I'm doing it for free. It opens child windows using the code below, which is triggered by the onclick event of various buttons:

    function ShowWin(url,w,h){
    features='screenX=320,screenY=60,left=320,top=30,resizable,height=' + h + ',width=' + w + ',scrollbars';
    win=window.open(url,"win",features,true);
    win.resizeTo(w,h)
    win.focus();
    }

    It works (still localhost at this point) in my Firefox, but in my IE8 the buttons do nothing till I say 'Allow blocked content' in the little bar that opens at the top: "Internet Explorer has restricted this web page from running scripts or ActiveX controls...".

    I have two questions:

    1. Is this pretty standard across browsers, or are only a few people going to encounter this problem? Is it just how mine is configured, for example, with my Firefox being configured one way and my IE8 the other way?

    2. Assuming I have to provide for child windows without this problem, is there an easy way to do that? I have done it with ColdFusion and Ajax in the past, but the site will not have ColdFusion on it, and I'm out of practice with ColdFusion and especially Ajax. Can it be done with boxes of some sort, made invisible, and only becoming visible when the buttons are clicked, with maybe a little button with an 'X' label inside the box, which sets its visible property to off? I'm looking through my CSS books (which I'm also not a guru in) to see what I can find, but can someone point me in the right direction? Which properties of which HTML tags should I be using? (Hopefully ones which will work in both Internet Explorer and Netscape-style browsers!) By the way, the contents of the child window are nothing but pictures and text.

    Thanks for your help.

    Peyton

    P.S. Another little problem, perhaps insurmountable: one of the little windows has enough text that it needs to scroll. But only just barely - maybe I can make it wider or use a smaller font...
    Reply With Quote
      #2  
    Old 10-31-2009, 04:05 PM
    mitya mitya is online now
    Registered User
     
    Join Date: Oct 2003
    Location: Nottingham
    Posts: 668
    This is an opportune time for you to move away from pop-up windows (which are frowned upon these days) and into DHTML pop-up 'windows' (actually DIVs), such as the show/hide method you described.

    The fact that IE8 is blocking your pop-ups - even on a click event, which most browsers usually allow - is down to the security zone configuration in tools > internet options. There's nothing you can do about this except take comfort that FF and Opera etc users will be unaffected.

    There are many examples of and tutorials for the DHTML approach online and there are several ready-made jQuery examples for this. The concept is simple: instead of opening a window onclick, you make a DIV visible instead. You can position it and write to it just as you would a genuine window. Build into it a close button graphic which, when clicked, duly reverts the DIV back to hidden.
    Reply With Quote
      #3  
    Old 11-02-2009, 11:22 AM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    Working so far, but..

    Thanks, mitya. That method is working for most of my DIV windows. But one of them contains tables within it, and they don't show up. Are tables forbidden with DIVS, as perhaps contrary to the spirit of the thing?
    Reply With Quote
      #4  
    Old 11-02-2009, 11:26 AM
    mitya mitya is online now
    Registered User
     
    Join Date: Oct 2003
    Location: Nottingham
    Posts: 668
    No reason they shouldn't show up. Is the table hardcoded into the DIV or being DOM-scripted on the fly? Any JS error? Sure it's not hidden by CSS? etc.
    Reply With Quote
      #5  
    Old 11-02-2009, 12:02 PM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    Solved, but...

    The table is hard-coded, and the version of it I had just before posting my question was super simple. Of the suggestions you made, the hidden by CSS seems closest to being right, because I managed to solve it by playing with the fonts (in CSS classes) - in fact the first time anything appeared in the DIV was when I got rid of all the classes. Unfortunately I didn't save the various stages along the way, so I can't tell you exactly what font or its absence was at fault. Thanks for your help, though. At the very least it inspired me to keep trying!

    Peyton
    Reply With Quote
      #6  
    Old 11-03-2009, 09:19 AM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    Switched to DIVs, but IE8 still complains!

    Okay, I have now rewritten the site with all its child windows turned into DIVs which are set either to display="none" or display="block", and everything is working fine... on Firefox.

    But IE8 *still* gives me the "Internet Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer" error message.

    Incredibly, even when I remove every single call to a Javascript function in the page (every onclick, onmouseover, etc. on every button in the page), I *still* get that message.

    It's only when I remove all the Javascript functions themselves that IE8 ceases to complain with this message!

    Yet a client of mine has a complex website I have written in Coldfusion, with lots of Javascript and AJAX in it, and none of his users (which includes office personnel I worked with in developing the site) have ever complained of that message. I can also run that site localhost on my own computer and not receive that message. Yet all of this is in Internet Explorer, which the client has standardized on. Due to differences in how IE and FF interpret fonts, the site doesn't even look right in FF. (The only people that ever use it are employees of his company - some of them in his office, others elsewhere in the city.)

    What could I be doing wrong?

    It's true I've been testing the page I'm writing now (which consists entirely of HTML and Javascript - and now, in fact, of a single webpage) by just dragging files off their directory onto the browser, but that shouldn't matter, right?

    Peyton
    Reply With Quote
      #7  
    Old 11-03-2009, 09:22 AM
    mitya mitya is online now
    Registered User
     
    Join Date: Oct 2003
    Location: Nottingham
    Posts: 668
    Sounds bizarre to me. If IE is moaning at the mere sight of any JavaScript then that's very odd - have you tried this on other computers? Sounds like you have a security zone setting akin to how Outlook etc renders HTML e-mails!
    Reply With Quote
      #8  
    Old 11-03-2009, 09:43 AM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    Same story on two computers

    Yes, I've tested it on my other computer, also a Windows XP Pro, and I get the same result. I even get it after setting all internet zones to the default level of security (Tools > Internet Options > Security).

    Actually the only thing I tested on the other computer was the page still with all its Javascript and buttons firing off the Javascript. But in principle those should not be a problem, right?

    I'll be glad to send the page if you like...
    Reply With Quote
      #9  
    Old 11-03-2009, 09:45 AM
    mitya mitya is online now
    Registered User
     
    Join Date: Oct 2003
    Location: Nottingham
    Posts: 668
    Sure - give me an address and I'll run it in my IE8.
    Reply With Quote
      #10  
    Old 11-03-2009, 10:10 AM
    criterion9 criterion9 is offline
    Registered User
     
    Join Date: Jan 2009
    Posts: 997
    The problem is because IE renders pages not served through a server (even localhost) in a security sandbox. IE will throw an error for many common javascript functions (especially anything to do with AJAX) since that could potentially open up the users computer to have the local filesystem changed. Try running the code through IIS or apache and I'm almost certain your warning will disappear.
    Reply With Quote
      #11  
    Old 11-03-2009, 12:52 PM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    IE8 is now mostly cooperating, but...

    Thanks again, guys.

    criterion9, your point that the problem with IE complaining about my Javascript really was the fact I was just dragging files into it turned out to be true. When I access the page as http://localhost, that problem disappeared. Whew!

    mitya, thanks for being willing to look at my page, which I have gone ahead and put on the web. It can be accessed at www.davinsinterpreting.com. Even though that big problem is now solved, you might like to see what your advice made possible.

    Actually, there does remain one slight problem, which relates to HTML instead of Javascript. (It's only because of that problem that I have made the table borders temporarily visible, while I'm still trying to solve it.) Again with IE though not with FF, the way I originally wrote it with the arrangement of items on the page accomplished by means of two separate tables, a couple of the window-simulating DIVs had their borders drawn only where the DIV overlapped the bottom table (the bottom row of the current table) and not all the way around the full DIV rectangle (but usually only when each DIV is first made visible, not after that).

    In the version now on the web, I have gotten around that problem by combining the two tables into one, but now the arrangement of things looks crappy since it refuses to obey me when I specify that the two upper right hand cells should span two columns.

    Actually, come to think of it, I may have to go back to the two-table solution because, if you maximize the browser window (at least on my wide screen monitor), it spreads the middle columns of the table out much too widely. The two-table version had another column just after the blurb about Davin's Interpreting Service, to delimit its right hand edge.

    Peyton

    Last edited by peytontodd; 11-03-2009 at 01:01 PM. Reason: Extra paragraph
    Reply With Quote
      #12  
    Old 11-03-2009, 02:20 PM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    Problem Solved

    Okay, I got it working. The solution was not to specify the size of the lower right hand columns as 200 and 300, adding up to the 500 specified for the cells above them which were colspan="2", but rather to omit any width specification for them.

    The final product (subject to some tweaking of course) can be witnessed at www.davinsinterpreting.com.

    And again many thanks,

    Peyton
    Reply With Quote
      #13  
    Old 11-03-2009, 08:32 PM
    wbport wbport is offline
    Registered User
     
    Join Date: Sep 2008
    Location: Jackson MS
    Posts: 50
    I think you already discovered IE8 always asks permission when running web pages which reside on your pc. When checking out my own stuff I either have to test it with Front Page or go thru the hassle of IE8 until it is uploaded.
    Reply With Quote
      #14  
    Old 11-03-2009, 08:53 PM
    peytontodd peytontodd is offline
    Registered User
     
    Join Date: Aug 2009
    Posts: 23
    Yep...

    Who woulda thunk it? I know I just assumed that of course the reason for my troubles couldn't be that I was just dragging the files to the browser. But I guess Microsoft is so often the target of viruses and malware that they're being particularly careful.

    Peyton
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 07:04 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.