这是我的代码:
现在,如何在会话中保存这些内容,以便每当我转到新链接时,该表仍然存在。多谢你们。
<body>
...
<script>
// Callback after window is loaded
if (window.addEventListener) {
window.addEventListener("load", downloadFilesAtOnload, false);
} else if (window.attachEvent) {
window.attachEvent("onload", downloadFilesAtOnload);
} else {
window.onload = downloadFilesAtOnload;
}
function downloadFilesAtOnload() {
// List of Javascript files to be loaded
var jsFiles = ["js/library1.min.js", "js/library2.min.js", "CDN.library3.min.js"];
loadScriptArray(jsFiles, function() {
triggerEvent(document, 'scripts_loaded');
});
// List of CSS files to be loaded
var robotoFonts = "https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic,500,500italic,700";
var cssFiles = ["css/cssfile1.min.css", "css/cssfile2.min.css", robotoFonts];
for (var i = 0; i < cssFiles.length; i++) {
var l = document.createElement('link');
l.rel = 'stylesheet';
l.href = cssFiles[i];
var h = document.getElementsByTagName('head')[0];
h.parentNode.insertBefore(l, h);
}
}
function loadScriptArray(contentArray, contentLoadedCallback){
var contentQuantity = contentArray.length; //Number of Files that needs to be loaded
var contentCompleted = 0; //Number of Files, that have already been loaded
for (var i = 0; i < contentQuantity; i++) {
loadScript(contentArray[i], function(success, path){ //This anonymous function is called everytime a script is finished
//The only way to know which script finished, is to pass the path as an parameter
contentCompleted++;
if (contentCompleted == contentQuantity){ //this was the last file
if (typeof contentLoadedCallback == 'function'){
contentLoadedCallback();
}
}
});
}
}
function loadScript(path, scriptLoadedCallback){
element = document.createElement("script");
element.src = path;
element.async = false;
if (typeof(scriptLoadedCallback) == 'function') { //makes the callback-function optional
element.onload = function() {
return scriptLoadedCallback(true, path); //true = successfull; the path is needed later
};
element.onerror = function() { //you might also call the cb on error
this.parentNode.removeChild(this); //remove faulty node from DOM
return scriptLoadedCallback(false, path); //false = error; the path is needed later
};
}
document.body.appendChild(element); //insert the node in DOM (end of <head>), and load the script
}
function processEvent(el, eventName, handler) {
if (el.addEventListener) {
el.addEventListener(eventName, handler);
} else if (el.attachEvent) {
el.attachEvent('on' + eventName, function() {
handler.call(el);
});
}
}
function triggerEvent(el, eventName) {
var event;
if (window.CustomEvent) {
event = new CustomEvent(eventName);
} else {
event = document.createEvent('CustomEvent');
event.initCustomEvent(eventName);
}
el.dispatchEvent(event);
}
</script>
</body>
答案 0 :(得分:0)
在会话中存储$ row:
$_SESSION['rowdata'] = $row;
或者序列化$ row来存储它,并在你想要使用它时取消序列化:
//Store
$_SESSION['rowdata'] = serialise($row);
//get back
$row = unserialise($_SESSION['rowdata']);