/ Published in: JavaScript
Expand |
Embed | Plain Text
/* For popups: <a href="http://google.com" title="" rel='popup:{"width":"200","height":"200","title":""}'> augue ut enim </a> */ $("a[rel^='popup']").bind("click", function(e) { var url = $(this).attr("href"), rel = $(this).attr("rel"), windowSettings = JSON.parse(rel.match(/{(.*)}/)[0]) || $.parseJSON(rel.match(/{(.*)}/)[0]) || { status: 1, toolbar: 1, location: 1, menubar: 1, directories: 1, resizable: 1, scrollbars: 1, height: 400, width: 400, title: "" }, windowSettingsStr = [], counter = 0; for (var i in windowSettings) { windowSettingsStr[counter] = i+"="+windowSettings[i]; counter += 1; } var n = window.open(url, windowSettings.title, windowSettingsStr.join(",")); if (window.focus) { n.focus(); } e.preventDefault(); });
You need to login to post a comment.
