Hi there
I have a piece of javasacript code that searches through several iframes for buttons with specifi id's. When I find the button, I bind a click event to the button. This works perfectly fine in IE, but only works in Firefox if I alert something, and upon clicking ok on the alert box, the button clicks works fine. Here's my code
$.each(iframe, function(index, ifrm) {
// Add target="_blank" to text hyper links
var hyper = null, hyperCount = 0;
hyper = $(ifrm).contents().find("a");
hyperCount = hyper.length;
for (var t = 0; t < hyperCount; t++) {
if (!$(hyper[t]).attr("target")) {
$(hyper[t]).attr("target", "_blank");
}
}
// end here
var tmp = $("#hdnButtonActions-" + index).val();
if (tmp !== "") {
var actions = tmp.split(",");
for (var i = 0; i < actions.length; i++) {
var button = actions[i].split("=");
var id = button[0];
var targetType = button[1];
var target = button[2];
var targetIndex = button[3];
//var ctrl = null;
if (targetType === "Page") {
$(ifrm)
.contents()
.find("button[id='" + id + "']")
.bind('click', { inx: eval(button[3]) }, pageHandler);
}
if (targetType === "Link") {
$(ifrm)
.contents()
.find("button[id='" + id + "']")
.bind('click', { url: button[2] }, linkHandler);
}
}
}
});
function pageHandler(event) {
$tabs.tabs('enable', event.data.inx);
$tabs.tabs('select', event.data.inx);
return;
}
function linkHandler(event) {
window.open("http://" + event.data.url);
return;
}
The click events either allows for a user to navigate to a specific jquery ui tab, or navigate to an external url which opens in a new window