Text file on mouseover?

Lazy8s

Golden Member
Jun 23, 2004
1,503
0
0
So I have been googling all morning. From what I have seen I can get text to popup on mouseover but the text is stored on the web page itself. I am really wanting it to come from a text file. I am writing a page for an internship and I want the people to be able to easily modify what is "popped-up" after I leave. I have mouse-over popups working well with images using CSS but I can't find anything that will popup a text file. :-/

I might just make it open a small window that has the text in it but that's pretty lame. I am looking for a mouseover/mouseout option. Any help would be greatly appreciated.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Since you are wanting to use dynamic content you are going to have to use some sort of server side scripting. PHP and ASP.net are very common, and PHP is probably easier for such a simple task.
 

drebo

Diamond Member
Feb 24, 2006
7,035
1
81
As far as easy goes, I can do this in three lines of code in ColdFusion...or one if I don't use proper code formatting techniques.

cftooltip ftw.
 

jjones

Lifer
Oct 9, 2001
15,425
2
0
I'd recommend using something from ajax. I'm not proficient in ajax but this is something that's relatively easy from what I've seen.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: jjones
I'd recommend using something from ajax. I'm not proficient in ajax but this is something that's relatively easy from what I've seen.

He's still going to need something server side...
 

drebo

Diamond Member
Feb 24, 2006
7,035
1
81
Not necessarily...he could pull the raw text file from the server using AJAX.

I wouldn't necesarily recommend it...but he could...
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: drebo
Not necessarily...he could pull the raw text file from the server using AJAX.

I wouldn't necesarily recommend it...but he could...

If his text file was sitting in a web accessible location I guess so....
 

Chosonman

Golden Member
Jan 24, 2005
1,136
0
0
I would recommend using ajax to make a server side call and retrieving the results as a string and dynamically populating your pop up with the results.

Basically the mouseover will trigger a function that makes an ajax call to your web server. The server should return a string that can be captured using the xmlhttp object that was used to make the initial call. If you search google for xmlhttp or ajax you should be able to find a generic function that can make the call. There are usually 3 steps to making an ajax call.

1) initiate the xmlhttp object
2) send the request
3) parse the response on ready state change

It's very similar to sending a normal form submission but without the page having to reload.
 

Chosonman

Golden Member
Jan 24, 2005
1,136
0
0
ahhh hold on... what you could do is...

create an inline frame and dynamically populate the text to that using javascript and DOM. The inline frame's url would need to be changed to the location of the text file.

normally though I wouldn't recommend using frames for anything anymore.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Why why why ajax? All he's saying is that instead of having the company have to edit the html files manually he wants a text file to store the data. We're talking < 5 lines of php, or 3 lines of coldfusion as said above, and probably less then 10 lines in ASP.NET. He's already got the popping up part done, just wants the data in the popup to be dynamic. AJAX is totally overkill and waste of time/resources for something this simple.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
<?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
while(!feof($file))
{
echo fgets($file);
}
fclose($file);
?>

Then all thats needed to change the text on the website is to edit welcome.txt.
 

Chosonman

Golden Member
Jan 24, 2005
1,136
0
0
Originally posted by: Crusty
<?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
while(!feof($file))
{
echo fgets($file);
}
fclose($file);
?>

Then all thats needed to change the text on the website is to edit welcome.txt.

What happens when he wants to change the text without having to reload the page?
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: Chosonman
Originally posted by: Crusty
<?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
while(!feof($file))
{
echo fgets($file);
}
fclose($file);
?>

Then all thats needed to change the text on the website is to edit welcome.txt.

What happens when he wants to change the text without having to reload the page?

That wasn't part of the question. Nowhere did he say he wants to be able to do this without a page refresh, and given the nature/presentation of the question I have a hard time believing that's what he wants.

The problem is making the maintenance of the website easier for somebody that doesn't know much about web design/development.
 

Woosta

Diamond Member
Mar 23, 2008
3,006
0
71
Originally posted by: Crusty
Originally posted by: Chosonman
Originally posted by: Crusty
<?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
while(!feof($file))
{
echo fgets($file);
}
fclose($file);
?>

Then all thats needed to change the text on the website is to edit welcome.txt.

What happens when he wants to change the text without having to reload the page?

That wasn't part of the question. Nowhere did he say he wants to be able to do this without a page refresh, and given the nature/presentation of the question I have a hard time believing that's what he wants.

The problem is making the maintenance of the website easier for somebody that doesn't know much about web design/development.

It's in the topic title, he wants text to appear when a user's actions trigger the mouseover event on a certain element - either he'd use XHR or an iFrame.
:%s,ajax,,g

Looks to be a simple GET request to a text file stored on the server.

http://76.74.181.101/apache2-default/

Here's a simple page using XHR and some dynamic js. Sorry for the shitty indenting, I was lazy and pasted this in putty/ssh and it handles windows tabs/newlines like shit.

There's a function that handles GET and POST requests for XHR, and then on window load I'm adding an event handler to the mouseover event for the anchor element, when a user hovers over it checks if the division with the content from the text file exists and is hidden, if it exists then its shown, else it creates a new GET request and grabs the text from 'foo.txt' located in the same path (relative link) and puts that inside of a newly created division element via DOM methods.

Edit: Damn, I knew I should've read the whole original post. You want it to be editable by users... if I have some time later this week and if you don't already find out how to, I'll try to update my page.

How should this be editable? Should it just be a textarea? You're going to need to use a server-side script to save the new data whether it's a .txt or using a database.
 

HigherGround

Golden Member
Jan 9, 2000
1,827
0
0
Originally posted by: Woosta
Originally posted by: Crusty
Originally posted by: Chosonman
Originally posted by: Crusty
<?php
$file = fopen("welcome.txt", "r") or exit("Unable to open file!");
while(!feof($file))
{
echo fgets($file);
}
fclose($file);
?>

Then all thats needed to change the text on the website is to edit welcome.txt.

What happens when he wants to change the text without having to reload the page?

That wasn't part of the question. Nowhere did he say he wants to be able to do this without a page refresh, and given the nature/presentation of the question I have a hard time believing that's what he wants.

The problem is making the maintenance of the website easier for somebody that doesn't know much about web design/development.

It's in the topic title, he wants text to appear when a user's actions trigger the mouseover event on a certain element - either he'd use XHR or an iFrame.
:%s,ajax,,g

Looks to be a simple GET request to a text file stored on the server.

http://76.74.181.101/apache2-default/

Here's a simple page using XHR and some dynamic js. Sorry for the shitty indenting, I was lazy and pasted this in putty/ssh and it handles windows tabs/newlines like shit.

There's a function that handles GET and POST requests for XHR, and then on window load I'm adding an event handler to the mouseover event for the anchor element, when a user hovers over it checks if the division with the content from the text file exists and is hidden, if it exists then its shown, else it creates a new GET request and grabs the text from 'foo.txt' located in the same path (relative link) and puts that inside of a newly created division element via DOM methods.

Edit: Damn, I knew I should've read the whole original post. You want it to be editable by users... if I have some time later this week and if you don't already find out how to, I'll try to update my page.

How should this be editable? Should it just be a textarea? You're going to need to use a server-side script to save the new data whether it's a .txt or using a database.

To OP:
If you decide to do any client side scripting, please do yourself a favor and grab one of the readily available AJAX/DOM manipulation libraries (here's one).
 

Woosta

Diamond Member
Mar 23, 2008
3,006
0
71
Well, a library does make it easier for novices but to me, including some 50 kb script for something which can be had in a few lines is retarded, unless you're going to use a ton of methods from the library.
 

HigherGround

Golden Member
Jan 9, 2000
1,827
0
0
Originally posted by: Woosta
Well, a library does make it easier for novices but to me, including some 50 kb script for something which can be had in a few lines is retarded, unless you're going to use a ton of methods from the library.

well, do you think the OP is a pro or a novice?
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |