0

<script>
function close(){
window.open('alert_update.php?id=<? echo"$alertm[id]"; ?>','alert');
document.getElementById("alert").style.display="none";
}
</script>

The above script is what I am using to send a request as such to alert_update (the file that updates the database which is a small iframe 1px by 1px; but I also need it to onclick hide the div that is showing the alert (as well as holding the iframe) although for some reason it wont do either and so im not sure if its something to do with my code, I'm not great at javascript.

My code to execute the function is:

<a href="#" onClick='close()'>Okay</a>

3
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by Airshow
0

I did try editing my script above to visability="hidden" and on the div style visibility: visible. but it had no effect :(

0

Do you have Firebug, if not get the extension for firefox. press F12 to open it and then go to the console panel refresh the page and then say what the error message is, if there is an error message

0

Think I may have a javascript error on the page that is importing the page that holds the div with the div hide. The reason for this is the hide works fine on its page itself, although, when on the other page it doesn't work. its quite odd.

0

When on the other page the error is:

element.style is undefined
[Break On This Error] element.style.display = 'none';

0

Public-image,

If I understand correctly, you want window.open('alert_update.php?id=<? echo"$alertm[id]"; ?>', 'alert'); to open an invisible child window, which will exist solely to handle the alert_update.php request (and its response).

You can do it this way but the code would be substancially different - chiefly in that a window opened with window.open(...) cannot be addressed with document.getElementById(...), which addresses DOM elements not windows.

In the old days (until about 5 years ago) the preferred approach would have been to use an iframe into which alert_update.php was loaded, but that approach has been superceded by AJAX.

Under AJAX (which is just a javascript pattern, not a language in its own right) an HTTP request is submitted and its response handled by javascript directly, not involving neither an iframe nor a child window.

If my understanding is correct, then yours is a classic problem for which AJAX is the most appropriate solution.

There are many good texts on AJAX out there on the internert and I won't try to better them. Try Googling "AJAX tutorial".

Airshow

Edited by Airshow: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.