views:

278

answers:

4
+1  Q: 

Fancybox loading

Hi,

Is it possible to init Fancybox plugin without document.ready() event ? In FF, it seems to be success but not in IE

To explain : I try to init all jquery functions at bottom of my page :

<script type="text/javascript">
            $(".overview_picM").fancybox({
                'titleShow': false,
                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                left: picLLeft,
                'autoScale': false,
                hideOnContentClick: true,
                overlayShow: false
            });
</script>
</body>

Without document.ready() or window.load, because they slow down.

This is not conventionnal in jquery using, i know, but i have ActiveX, Java Applet or Iframe and all this elements slow down jquery accessibility by using document.Ready or window.load (...)

I have started to implement jquery scripts by this method, and it's successfull for many of my scripts (jquery).

An idea ? Best Regards,

Sebastien

EDIT : See explanation to clarify the needs and solutions, below

A: 

I think that as long as you put the init code AFTER the element on which you would like to apply it (in your case it's something with "overview_picM" class), this should be working.

IgalSt
A: 

It doesnt matter when you call the init as long as you do it after the DOM element has loaded.

Byron Cobb
I tried but in Ie, fancybox doesn't matter if all elements are not loaded (iframe,...). If I click on "overview_picM" to show fancybox, before iframe is loaded, IE returns some errors : "loading is null or not object" (...)
Sébastien
A: 

Thanks for yours responses. In my page, there is an iframe with an applet java inside.

With IE, durring iframe and applet loading, fancybox functionnality doesn't work when jqeury code is at bottom of my page or under my element overview_picM.

In IE, Fancybox works only when iframe has finished to be loaded. Even if, i don't use document.ready. I don't understand why. Is it a threading conflict in IE, between iframe loading and fancybox plugin ?

Sébastien
What you could do is call a javascript function to load the fancybox on the iframe loaded event. Remember to mark an answer as correct if it solves your problem and vote up if it helps you.
Byron Cobb
<iframe id=myiframe src=somepage.html onLoad=some_javascript_function()></iframe>
Byron Cobb
Thanks for your responses. But it's not what I want to do. My english is not very good, sorry :)I would like use fancybox functionnality even if iframe not loaded yet. This is usefull with FireFox but not IE.
Sébastien
To clarify : I would like use fancybox functionnality in base Page even if an iframe not loaded yet in this base Page.
Sébastien
Why can't you use the $(document).ready in the base page then? The document.ready in the base page will be fast enough to load the fancybox before the iFrame even starts loading. You dont have to do the document.ready in the iframe page.
Byron Cobb
I don't use document.ready in the iframe page.In my base page, I would like to load fancybox on an img element to show this biggest before iframe (wich is in base page too) be loaded. This iframe seems to take many seconds to be load. So, I noticed that during iframe loading, i can't use fancybox. I think fancybox needs DOM be ready to be used correctly, under IE. Under FF, it's not necessary.Initial question was not correctly formulated. Sorry.
Sébastien
A: 

First, Thank to Byron for his patience

To explain and Clarify my need :

In my base page, I would like to use fancybox on an <img> element to show this element biggest, before iframe (which is in base page too) be loaded.

This iframe contains java Applet and seems to take many seconds to be load/ready (?) in DOM.

So, I noticed that during iframe loading, i can't use fancybox. Maybe, fancybox needs DOM be ready to be used correctly, under IE. Under FF, it's not necessary, after many tests. So, I think for threading conflict in IE.

Initial question was not correctly formulated. Sorry.

So, to resolve this problem, I load iframe src in a setTimeout at bottom of my page :

        setTimeout('initSrcIframes()',0);

        function initSrcIframes() {
            $("iframe#iframeViewer3D").attr("src", "myUrl.aspx");        

        }
</script>
</body>
</html>

By this way, I can use fancybox plugin as soon as possible in my base page and not after iframe be loaded. I think by setTimeout method, i start new thread (in base page) to load iframe src without penalizing many javascripts features.

I hope this answer clarify my need and will help some people :)

Sébastien

Sébastien