Initial Commit
This commit is contained in:
45
indexes/user/process/iframe.js
Normal file
45
indexes/user/process/iframe.js
Normal file
@@ -0,0 +1,45 @@
|
||||
function details(tag){
|
||||
var name = tag.id;
|
||||
makeIFrame('./item_details.php?myParam=' + name);
|
||||
}
|
||||
|
||||
function makeIFrame(url) {
|
||||
var existence = document.getElementById("detail_window");
|
||||
if (!existence) {
|
||||
// Create the overlay div and add it to the page
|
||||
var overlay = document.createElement("div");
|
||||
overlay.id = "overlay";
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
// Create the iframe and add it to the overlay div
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("src", url);
|
||||
iframe.id = "detail_window";
|
||||
overlay.appendChild(iframe);
|
||||
|
||||
// Create the close button and add it to the overlay div
|
||||
var closeButton = document.createElement("button");
|
||||
closeButton.innerHTML = "x";
|
||||
closeButton.title = "Close";
|
||||
closeButton.id = "closebutton";
|
||||
overlay.appendChild(closeButton);
|
||||
|
||||
// Add event listener to close the iframe when the close button is clicked
|
||||
closeButton.addEventListener("click", closeIFrame);
|
||||
|
||||
// Add event listener to close the iframe when clicked outside
|
||||
setTimeout(function() {
|
||||
overlay.addEventListener("click", closeIFrame);
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to close the iframe and remove the overlay div from the page
|
||||
function closeIFrame() {
|
||||
var overlay = document.getElementById("overlay");
|
||||
if (overlay) {
|
||||
overlay.removeEventListener("click", closeIFrame);
|
||||
overlay.parentNode.removeChild(overlay);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user