Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

popup - if there's content in a file?

Status
Not open for further replies.

simmerdown

Programmer
Jun 6, 2000
100
0
0
US
I'm developing an emergency-classes-canceled alert system on an educational site, and I'd like to pop up a new window with the relevant announcements [COLOR=cc0000]if there are any announcements to be made.[/color] That is, if the appropriate file on my server is empty/null/has no content, I don't want the window popping up.

I already know how to pop open a new window, it's the conditionality that's got me stumped.

Is this feasible without resorting to ColdFusion or .asp? I'm limited to inserting code into existing pages, and I don't have the freedom to modify those pages into a CF app or something else. So if you've got a bit o' JavaScript magic for me, I'd much appreciate it.
 
I'm having a similar problem, given the age and nil responses to simmerdown's post am I to assume there isn't a solution to this?

My problem is slightly different in that I only want to display a pop-up if the html file itself exists, at the moment I just get the 404 error.
 
simmerdown, as your file is SERVER side, unless you use server side javascript (requiring you can access the web server ...), this can't be done using javascript ... so, yes, you have to use another language (i would suggest php as it's very light and yet powerful)
timjwild, i suppose you'll have to use a sever side language as well ...
 
Well, I ended up cobbling together a not-very-flexible means of humbly accomplishing what I needed. I wrote a bit of secured ColdFusion admin that allowed authorized users to fill out a form with the message they wanted to display. I then had CF take that content and [by CFFILE] write it into a message.js file tucked away on the server.

The file usually just looks like this:
[COLOR=003366]var msg = ""[/color]

but cf overwrites it to look like this:
[COLOR=003366]var msg = "The message here"[/color]

Then in each page header, another bit of js asks for that variable. If the variable string is empty, nothing shows up in my html; if there's any content in the string, it appears. Be sure to escape your quotes properly, but with some care you can add html code into that string as well. As it works now, I place an <img> tag and the message into the string ... and thus into the html page.

Was that understandable? It worked for me.
 
yes, as cf is server side it had to work !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top