-4

Due to a requirement i'm trying a solution to write a script/code that helps me auto-refresh the web page every 15 seconds or so. And also doing using a loop to continuously search for a word (or string of words). When it finds the word, it would also be helpful to alert the user that the word has appeared! in some way sending a SMS to a mobile.

Could this be done in .NET?

In a stock account, after 9PM to 6AM the status of the stock exchange will be changed from CLOSED to AFTER_HOURS. I'm trying a way to find the same

venkat
  • 5,648
  • 16
  • 58
  • 83
  • 3
    http://mattgemmell.com/2008/12/08/what-have-you-tried/ – David Aug 31 '12 at 18:31
  • 4
    I was not the downvoter, but I'm sure that the post I linked to is the reason why. However, I DID vote to close as not a real question. There isn't a specific coding issue you're asking for as per the FAQ. As it's worded, however, the answer is "Yes. It's possible." – David Aug 31 '12 at 18:31
  • Due to some requirement i need this functionality. So i'm googling for the way to get the same – venkat Aug 31 '12 at 18:32
  • Personally, I would not do it in script. I'd use a System.Net.WebClient to call the web page, look for the string, and then use a third party web service to send the SMS. There are tons of services out there that have APIs for sending SMS messages. But that's a guess, because really, you haven't provided any information about whether this is a page that YOU generate, or some other page. Based on the overall architecture my answer would probably change greatly, as would anyone else's. That's why the FAQ asks for specific programming questions, not broad general ones like this. – David Aug 31 '12 at 18:35
  • @DavidStratton: I modified my query. Please Re open the question from CLosed – venkat Aug 31 '12 at 18:47

2 Answers2

1

A simple code that auto-refress the web page is to add a meta tag on the header:

<meta http-equiv="refresh" content="60" >

the parameter is in seconds, and you can also add and no cache to be sure that is going to reload it as:

<head>
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="refresh" content="60" >
</head>

after that, a more better way is a javascript timer that reads using ajax time to time your data and show to your user...

And How to play some sound on the browser

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
0

Well let's split the issues, I'll try to give you hints on each one:

Autorefresh

Add this to the section: <META HTTP-EQUIV="Refresh" CONTENT="5"> where CONTENT is your refresh rate in seconds.

Loop search word

You might be interested in this function:

setInterval(yourFunction, delay)

where yourFunction would be the function to search the string, and delay the time in miliseconds to repeat the function.

Sounds stuff

Using Jquery, I found an example here that might help you, modify to fit in your scenario:

HTML:

<html>
 <head>
    <script type='text/javascript' src='jquery.js'></script>
    <script type='text/javascript' src='script.js'></script>
 </head>
 <body>
    <div id="sound" class="hover">Hover here</div>
 </body>
</html>

JS:

$(function(){
    $('#sound.hover').mouseover(function(){
        $('embed').remove();
        $('body').append('<embed src="sound.wav" autostart="true" hidden="true" loop="false">');     
    }); 
});

Send SMS to mobile

Try this. It's a c# example using winforms. Other option here using an external service.

danielQ
  • 2,016
  • 1
  • 15
  • 19