Files
DDUtility/DDUtilityHelp/js/sb-custom-1.js
2025-02-03 11:02:48 +09:00

39 lines
1.5 KiB
JavaScript

function OnloadImg(url, title = '') {
if (title == '') { title = 'ImageViewer'; }
var img = new Image();
img.src = url;
var win_width = img.width;
var win_height = img.height;
var win_top = (screen.height / 2) - (win_height / 2);
var win_left = (screen.width / 2) - (win_width / 2);
var OpenWindow = window.open('', '_blank', 'width=' + win_width + ', height=' + win_height + ', top=' + win_top + ', left=' + win_left + ', menubars=no, scrollbars=auto');
var doc_head = "<head><title>" + title + "</title></head>";
var doc_style = "<style>html,body{height:100%;width:100%;} html{display:table;} body{padding:10px;display:table-cell;vertical-align:middle}</style>";
var doc_image = "<img src='" + url + "' width='100%' onClick='window.close()'>";
OpenWindow.document.write(doc_head + doc_style + doc_image);
}
// <a href="#url"> url.style.display='none'
function Close_IDofHref(obj) {
const id = obj.attributes.href.nodeValue.replace("#", '');
document.getElementById(id).style.display = 'none';
}
// <a href="#url"> url.style.display='block'
function Open_IDofHref() {
const id = this.attributes.href.nodeValue.replace("#", '');
document.getElementById(id).style.display = 'block';
}
function ToggleNextElement_Div() {
const element = this.nextElementSibling;
if (element.localName != 'div') return;
if (element.style.display == '' || element.style.display == 'none')
element.style.display = 'block';
else
element.style.display = 'none';
}