Hi All,
I have a problem with reloading JS.
I have a DIV where I placed JS code displaying random tricks & tips
from other site.
at the beggining I had it this way:
<div id="tips">
<script src="http://other.site.com/random_tt.php"> </script>
</div>
it works without any problem, random tip is displayed.
I wanted to change tips and tricks every 5 minutes, I wrote:
setTimeout('cha nge_tips()', 1000 * 60 * 5);
in change_tips function I have:
new_tt = document.getEle mentById('tips' );
new_tt.innerHTM L = '<script
src="http://other.site.com/random_tt.php"> </script>;
but... random tips are generated this way (the output of PHP script):
tip = 'some content'
document.write( tip)
it uses document.write to display random tip
how can I reload JS with document.write?
thanks in advance
best regards
R 4 1753
the easy way would be to use HTML: an iframe which calls a frameset
which refreshes every 5 mins, the content of which is just a child
frame which is the javascript from the other site.
the harder way is to use js to create and populate the iframe. using
dom compliant code.
my preferred way would be to write a php script on your own server
which gets the code from the other server, and then sanitizes it! I
mean if they get hacked you get hacked, since you are just
document.writin g it straight into yuor webpage.
Using php you could use a regular expression to get only text from
within ( ) and then spit that out as a js string variable
var sanitized_tip = 'never include content from other peoples sites
without being very careful';
you would then use the javascript you are currently using and set
sanitized_tip as the text you want to display in the div you have.
R wrote:
Hi All,
I have a problem with reloading JS.
I have a DIV where I placed JS code displaying random tricks & tips
from other site.
at the beggining I had it this way:
<div id="tips">
<script src="http://other.site.com/random_tt.php"> </script>
</div>
it works without any problem, random tip is displayed.
I wanted to change tips and tricks every 5 minutes, I wrote:
setTimeout('cha nge_tips()', 1000 * 60 * 5);
in change_tips function I have:
new_tt = document.getEle mentById('tips' );
new_tt.innerHTM L = '<script
src="http://other.site.com/random_tt.php"> </script>;
but... random tips are generated this way (the output of PHP script):
tip = 'some content'
document.write( tip)
it uses document.write to display random tip
how can I reload JS with document.write?
thanks in advance
best regards
R
I'm probably gonna get flamed for this but, I'm going to suggest
loading the tips in an iframe, so the doc.write will only overwrite the
iframe.
R a écrit :
Hi All,
I have a problem with reloading JS.
I have a DIV where I placed JS code displaying random tricks & tips
from other site.
at the beggining I had it this way:
<div id="tips">
<script src="http://other.site.com/random_tt.php"> </script>
</div>
it works without any problem, random tip is displayed.
I wanted to change tips and tricks every 5 minutes, I wrote:
setTimeout('cha nge_tips()', 1000 * 60 * 5);
in change_tips function I have:
new_tt = document.getEle mentById('tips' );
new_tt.innerHTM L = '<script
src="http://other.site.com/random_tt.php"> </script>;
but... random tips are generated this way (the output of PHP script):
tip = 'some content'
document.write( tip)
it uses document.write to display random tip
how can I reload JS with document.write?
thanks in advance
best regards
R
Bonjour,
innerHTML is a bad way ! (script isn't executed)
the simplest method :
use method .reload the entire document in function change_tips !
G
R said the following on 10/25/2006 9:45 AM:
Hi All,
I have a problem with reloading JS.
I have a DIV where I placed JS code displaying random tricks & tips
from other site.
at the beggining I had it this way:
<div id="tips">
<script src="http://other.site.com/random_tt.php"> </script>
</div>
it works without any problem, random tip is displayed.
I wanted to change tips and tricks every 5 minutes, I wrote:
setTimeout('cha nge_tips()', 1000 * 60 * 5);
in change_tips function I have:
new_tt = document.getEle mentById('tips' );
new_tt.innerHTM L = '<script
src="http://other.site.com/random_tt.php"> </script>;
And your new script never gets executed (unless you are using a very
early NS6 browser). Script elements inserted via innerHTML don't get
executed.
but... random tips are generated this way (the output of PHP script):
tip = 'some content'
document.write( tip)
it uses document.write to display random tip
how can I reload JS with document.write?
Without using either an IFrame to hold your tips (set the borders to 0
and no margins, you can effectively "hide" an IFrame so that it doesn't
appear to be an IFrame), or, you will have to have a script on your own
server that gets the file from the remote server, removes the
document.write statement, and then you can load the JS and insert the
tips. Seems like a lot of trouble, just make your own tips file and
randomly display them.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Greg Bryant |
last post by:
Wondering why my setcookies didn't have any impact, I noticed the line in
the manual that said the page needs to be reloaded before they take effect
(which does make a certain kind of sense). So, how do I force a page to
reload?
Thanks,
Greg
|
by: jbj |
last post by:
Something like a php function that can be called? I have php in a
page that needs to be update periodically (basically poll results)
without reloading the page around it (I do have a button you can
click). Is this possible? Or should I make some sort of Iframe with
the php page in it that could be reloaded.
The php code basicaly just writes a table to the page with the results
of the polls included. Thanks for the help.
|
by: J. J. Cale |
last post by:
Hi
Obviously I'm new to PHP. I would like to be able to update a table in a
page from a database on the server without reloading the page each time. Is
this possible with PHP?
TIA
Jimbo
|
by: Andy Jewell |
last post by:
Does anyone know of a way to dynamically reload all the imported modules of a
client module?
I'm writing a program that I have broken down into quite a few submodules, and
the 'configuration' is done with modules too. As I am developing the app, I
need to test bits and pieces here and there. This is what I currently do:
In each module, I have a section, just after the main imports like so:
|
by: aurora |
last post by:
I am looking for a way for reloading updated modules in a long running
server. I'm not too concerned about cascaded reload or objects already
created. Just need to reload module xxx if the corresponding xxx.py is
updated.
I found something useful in module.__file__. Would it work if I use it to
generate filenames xxx.py xxx.pyc and then compare their mtime? I'm not
too sure about the mechanism of generation of .pyc file. Would it be too...
| |
by: Aspersion |
last post by:
I'm building an ASP page that has a lot of text and graphics.
There is a calculation facility on the page. The user enters several
numbers in a form and presses a button to see the calculated answer.
The problem is this: when the user presses the Calculate button, the
whole page is reloaded and, on a large page, this is very noticeable.
Is there any way that I can get the calculation done and the result
displayed without reloading...
|
by: Anto |
last post by:
Hi,
We have a asp and the source is,
<%
Response.Expires = 0
appnum = Request.QueryString("appnum")
pdfpath = Application("pdfpath")
set objXML = server.createobject("TASJobReport1.JobReport")
x = objXML.PopulatePDF(appnum)
set objXML = nothing
|
by: Snolly |
last post by:
Hi all,
Here is my issue. I have a web page (lets call it page1) with an
iframe in it that then opens a pop-up window (page2). The pop-up
window is used to edit some data that was loaded into page1 so I want
to use onunload to reload page1 to keep the data synchronized.
At first I was using just
window.opener.parent.location = window.opener.parent.location;
|
by: Richard |
last post by:
Hey there,
I have a textbox and a listbox. When a user types a number in the textbox, I
want to get
all the records from a MS Access DB but without reloading the page. I now
have something manual
and a user first must press a button to get the listbox filled with records
but I want to have it done
automaticly without pressing a sumbit button. I know its prolly done with
javascript but thats one thing
|
by: andrewfelch |
last post by:
Hello all,
I'm using the metaclass trick for automatic reloading of class member
functions, found at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164
My problem is that if I
1) pickle an object that inherits from "AutoReloader"
2) unpickle the object
3) modify one of the pickled' object's derived class methods
4) reload the module holding the class
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |