I have made this script to open a fancybox from code behind, but it keeps saying "u is undefined"... not sure what's wrong
StringBuilder sb = new StringBuilder();
sb.AppendLine("<script>");
sb.AppendLine("$.fancybox('../Popups/EndedProduction.aspx?Iframe', {");
sb.AppendLine开发者_高级运维("'width': 557,");
sb.AppendLine("'height': 244,");
sb.AppendLine("'transitionIn': 'none',");
sb.AppendLine("'transitionOut': 'none'");
sb.AppendLine("});");
sb.AppendLine("</script>");
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Completed", sb.ToString());
Take a look at the generated source of the document(for example with HTML-tab in firebug) and be sure that you didn't embed the fancybox-script twice.
found a way around it.
<a id="popup" href="../Popups/EndedProduction.aspx?Iframe"></a>
<script type="text/javascript">
function test() {
$("#popup").fancybox({
'width': 557,
'height': 244,
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'iframe'
});
}
<% if (Current.Production.Status >= (Int32)ProductionStatus.Completed)
{ %>
$(document).ready(function () {
$("#popup").fancybox().trigger('click');
});
<%} %>
</script>
For what it's worth, I was setting up a function like what is posted in your original question, encountered the same error, and when I used the unpacked source the parameter was the "loading" var. A lot of stack overflow answers suggest this happens when the Flexbox script is loaded twice, but in my case it wasn't. The answer was simply wrapping the FancyBox call in jQuery(document).ready. Your solution does this but eliminates the original manual trigger, so I'm curious if this would have solved your problem.
精彩评论