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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Script not working in IE, working in FF & Opera

    I wanted to make a js script that would take a few classnames from a MySQL DB and select all images with those classnames.

    I did that with this part (this works):
    Code:
    new Ajax.Request( '/control/media/getClassNames', { onSuccess: 
    function (r) { 
    	r.responseText.evalJSON().each( 
    	function( type ) { 		
    		var imgs = $$( 'img.' + type );
    		imgs.each(function(img) { //do some stuff }
    so the php script returns a list of classnames JSON encoded. I use prototype js btw.

    Those classnames mean a certain format for the picture, in this example cc_mediapreview, means maxwidth=290px and maxheight=190px. This way I can dynamically define the size of certain classes of pictures.

    I used url="img_url" instead of src="img_url" to make sure that the browser doesn't try to load the (original)images at all.

    Then in the //do some stuff I do this:
    Code:
    var url = img.getAttribute('url');	
    //Use ajax to see if temp img exists, if it doesn't exist it will be created on the fly
    new Ajax.Request( '/control/media/temp_exists', { parameters: { 
    file: '/images/temp' + url.substring(url.lastIndexOf('/'),url.lastIndexOf('.')) + '_temp_' + type + url.substr(url.lastIndexOf('.')), 
    org_url: url, 
    class: type }, 
    onSuccess: 
    function (r) {
    	img.src = r.responseText;
    } 
    } );
    Again this works fine, it looks if there is a temp file and otherwise it creates one and echo's back the right src

    First this was all I wanted, but what it does is it waits for the body onLoad event to execute it. This isn't good because all (original)images would have to be loaded first before they would get replaced by the right (temp)images

    So I used a bit of code from http://www.brothercake.com/site/reso...ipts/domready/ so I could make it do all this before the images were loaded with:
    Code:
    var foobar = new domFunction(function () { imagesCCInit(); }, { 'img' : 'tag'});
    Code:
    imagesCCInit();
    is the function that makes a new object

    Code:
    var myImagesCC = null;
    function imagesCCInit() {
    	myImagesCC = new imagesCC();
    }
    This is where it goes wrong in IE, it throws back an error Object Expected on line 9. That is the line with domFunctions. Why does it do this and how can I fix it?

    You can check at http://www.clipcontrol.com that it works in both FF and Opera just great.

    Thanks for any help!

  • #2
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would like to mention that if I just use:
    Code:
    Event.observe(window, 'load', imagesCCInit, false);
    it works for all browsers.

    Thanks again!

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for the bump, but can no one help me?


  •  

    Posting Permissions

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