Calling javascript from inline HTML Floatbox

Page: 1

Author Post
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
Using the inline DIV content, I'm getting an error "Function()" is null or undefined. The function is in a script file that is included on the page the hidden DIV is on. But when called from the DIV's content in Floatbox, I get the error. I've already discovered that I need to re-include the .js file when loading floatbox by AJAX or IFRAME. Do I have to do that for my inline DIVs too? Or am I missing something?
Administrator
Registered: Aug 2008
Posts: 3382
I'll need to see the page to determine why this is happening.

Content loaded from a hidden div or via AJAX is part of the host page's document and its script execution context is the host page's window object. Script and document references in such content work exactly the same from inside a floatbox as they do from the main page. Iframe content creates its own document and window object. Scripts and document references in iframe content operate within that child window object's space.

To relate this to your case, if it is hidden div content in the floatbox, then the error arises from something other than the content being located within the floatbox at the time of execution.
Member
Registered: Apr 2013
Posts: 22
Location: Nevada Test Site, USA
So sorry, my bad! I am porting someone else's code from an older lightbox clone to your vastly superior one and I wasn't aware of errors it already contained. :oops:

But just to clarify - so you are saying that if I use AJAX then it will still execute in the calling page's context? Here is the link I am using:


<a title=&#039;View Details For This Item&#039; class="floatbox" data-fb-options="type:ajax" href="Floatbox.aspx?Keyword=18818&CustomerID=501&src=Spec">
Administrator
Registered: Aug 2008
Posts: 3382
Correct about AJAX loading. type:ajax content is assigned to a div that resides on the main page, and not to an iframe element which would contain its own separate document and window object.

Page: 1