|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
URL (NOT images) Slide Show with new window
Is it possible with javascript to create a "new window" upon "submit" that, once open, then cycles through multiple websites (examples below are Dow Industrials),
pausing for 4 seconds before advancing to the next website. Cycle continues until user closes "new window". Code:
http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=AA http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=AIG http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=AXP http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=BA http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=C http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=CAT http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=DD http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=DIS http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=GE http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=GM http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=HD http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=HON http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=HPQ http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=IBM http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=INTC http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=JNJ http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=JPM http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=KO http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=MCD http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=MMM http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=MO http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=MRK http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=MSFT http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=PFE http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=PG http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=SBC http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=UTX http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=VZ http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=WMT http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=XOM Insight: if frequent amended 10-Qs are filed . . . |
|
#2
|
||||
|
||||
|
maybe something like this:
Code:
<style type="text/css">
.hide{display:none;}
.show{display:block;}
</style>
<script type="text/javascript">
var timerId=null
var intervalPause=3000
var openNumber=0;
var elList=[];
onload=function(){
getIds();
timerId=setTimeout(daAnimationI,intervalPause)
}
function getIds(){
var e;
while(true){
e=document.getElementById("w"+(elList.length+1))
if(e)elList[elList.length]=e
else break;
}
}
function daAnimationI(){
clearTimeout(timerId)
daAnimation()
timerId=setTimeout(daAnimationI,intervalPause)
}
function daAnimation(){
elList[openNumber].className="hide"
openNumber++;if(openNumber>=elList.length)openNumber=0
elList[openNumber].className="show"
}
</script>
<div id="w1" class="show">
<iframe src="http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=AA" width="500" height="400"></iframe>
</div>
<div id="w2" class="hide">
<iframe src="http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=AIG" width="500" height="400"></iframe>
</div>
<div id="w3" class="hide">
<iframe src="http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=AXP" width="500" height="400"></iframe>
</div>
<div id="w4" class="hide">
<iframe src="http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=BA" width="500" height="400"></iframe>
</div>
<div id="w5" class="hide">
<iframe src="http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK=C" width="500" height="400"></iframe>
</div>
__________________
Ultimater XMLHttpRequest: Specification | xmlhttp object | open and onreadystatechange order | String.prototype.toXMLDocument | Sarissa | Prototype | Dojo Broadening one's horizons: 24ways.org Note I have a bad habit of editing my posts hours at a time and hours later. |
|
#3
|
|||
|
|||
|
Ultimater,
You have exceeded expectations! Works perfectly. Hopefully this quick scan of the frequency of SEC amended filings proves useful in any future investment decisions. |
|
#4
|
||||
|
||||
|
Then we should use valid HTML and include all of your URLS.
(please download the attachment and omit the ".txt" part)
__________________
Ultimater XMLHttpRequest: Specification | xmlhttp object | open and onreadystatechange order | String.prototype.toXMLDocument | Sarissa | Prototype | Dojo Broadening one's horizons: 24ways.org Note I have a bad habit of editing my posts hours at a time and hours later. |
|
#5
|
|||
|
|||
|
Ultimater,
Thanks again! I made two changes in the attached: 1) added id="w11" and renumbered remaining elements 2) changed window dimensions. I really appreciate your help on this matter. |
|
#6
|
||||
|
||||
|
Oh, flip, I can't count lol.
__________________
Ultimater XMLHttpRequest: Specification | xmlhttp object | open and onreadystatechange order | String.prototype.toXMLDocument | Sarissa | Prototype | Dojo Broadening one's horizons: 24ways.org Note I have a bad habit of editing my posts hours at a time and hours later. |
|
#7
|
|||
|
|||
|
Katy:
Here's another approach, consistent with your initial goal of using a separate window for the rolling SEC pages. This window also has Pause and Continue buttons. The main page has a button to re-open the window if the user previously closed it. If the user closes the main page, the pop-up window also closes. I receive an error for the stock symbol HD, so I substituted MSO. I tested the code in FF and IE. Main document: Code:
<HTML>
<Head>
<Script type="text/javascript">
var win10Q = "";
var winTogle = false;
function open10Q(){
if (win10Q != ""){win10Q.close()}
win10Q = window.open('10Q.html','','toolbar=0,statusbar=0,scrollbars=1,menubar=1,resizable=1,top=100,left=400,height=200,width=350');
win10Q.document.title = "SEC 10-Q";
winToggle = true;
}
function restart(){
win10Q = "";
winToggle = false;
open10Q();
}
window.onload=open10Q;
window.onbeforeunload=function(){
if (winToggle && !win10Q.closed){win10Q.close()}
}
</Script>
</Head>
<Body>
<input type='button' value='Re-start 10Q' onclick='restart()'>
</Body>
</HTML>
Last edited by MjhLkwd; 09-17-2005 at 08:57 AM. |
|
#8
|
|||
|
|||
|
Mike,
Thanks! I think I see where you are headed, but only ~25 lines of code are displayed above (just for one window?). I suspect there might be more . . . When you pre-viewed your post, was it all there? If so, then something got lost while making final publication. Please advise. |
|
#9
|
|||
|
|||
|
Katy: Ouch! Sorry. Here it is again, both documents.
Main: Code:
<HTML>
<Head>
<Script type="text/javascript">
var win10Q = "";
var winToggle = false;
function open10Q(){
if (win10Q != ""){win10Q.close()}
win10Q = window.open('10Q.html','','toolbar=0,statusbar=0,scrollbars=1,menubar=1,resizable=1,top=100,left=400,height=200,width=350');
win10Q.document.title = "SEC 10-Q";
winToggle = true;
}
function restart(){
win10Q = "";
winToggle = false;
open10Q();
}
window.onload=open10Q;
window.onbeforeunload=function(){
if (winToggle && !win10Q.closed){win10Q.close()}
}
</Script>
</Head>
<Body>
<input type='button' value='Re-start 10Q' onclick='restart()'>
</Body>
</HTML>
Code:
<HTML>
<Head>
<Script type="text/javascript">
var URLstr =
"http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK="
var ticker = new Array('AA','AIG','AXP','BAC','C','CAT','DD','GIS','GE','GM','MSO','HON','HPQ','IBM','INTC','JNJ','JPM','KO','MCD','MMM','MO','MRK','MSFT','PFE','PG','SBC','UTX','VZ','WMT','XOM')
var useWidth = screen.width-50;
var n = 0;
var pauseFlag = false;
var roll1 = "";
var first = true;
function pauseRoll(){
clearTimeout(roll1);
pauseFlag = true;
n--;
}
function continueRoll(){
pauseFlag = false;
rollFrame();
}
function rollFrame(){
clearTimeout(roll1);
if (!pauseFlag && !first)
{
if (n < (ticker.length-1)){n++}
else {n = 0}
roll1 = setTimeout("window.frames.secInfo.location.href = URLstr+ticker[n]",4000);
}
setTimeout('first = false',10);
}
function setUp(){
document.getElementById('A').setAttribute('width',useWidth);
window.frames.secInfo.document.write("<font size='4'>Loading...</font>");
window.frames.secInfo.location.href = URLstr+ticker[0];
}
window.onload=setUp;
</Script>
</Head>
<Body>
<IFRAME name='secInfo'
id='A'
Src = ''
onload='rollFrame()'
height='440'
frameborder='yes' scrolling='yes'>
</IFRAME>
<br>
<input type='button' id='pauseBtn' value='Pause' onclick='pauseRoll()'>  
<input type='button' id='continueBtn' value='Continue' onclick='continueRoll()'>
</Body>
</HTML>
Last edited by MjhLkwd; 09-17-2005 at 01:23 PM. |
|
#10
|
|||
|
|||
|
Katy:
Minor errors. Remove the commented line: Code:
function restart(){
//win10Q = "";
winToggle = false;
open10Q();
}
Also, a misspelling in the main document, this: Code:
var winTogle = false; Code:
var winToggle = false; Last edited by MjhLkwd; 09-17-2005 at 01:33 PM. |
|
#11
|
|||
|
|||
|
Mike,
Thanks for the alternate approach! This works well and is on the mark and fit for purpose. Regards, katydid |
|
#12
|
|||
|
|||
|
katydid:
You're welcome. There is one last change: In the 10Q.html document, in the rollFrame function, replace the last line with this: if (first){setTimeout('first = false',10)} make sure there is no semi-colon at the end of it. "first" only needs to be set to false once. Continuing to run that timeout every time the function is exectued is incorrect. |
|
#13
|
|||
|
|||
|
katydid:
There were two changes, but I forgot about the first one, because, truthfully, I assumed you weren't interested, because you didn't respond earlier today. Using the existing code, if a user clicks the pause button more than once while the first ticker is displayed, then n would be a negative number, and cause an error. Here's the corrected code for the function. Code:
function rollFrame(){
clearTimeout(roll1);
if (!pauseFlag && !first)
{
if (n < 0){n = 0}
else if (n < (ticker.length-1)){n++}
else {n = 0}
roll1 = setTimeout("window.frames.secInfo.location.href = URLstr+ticker[n]",4000);
}
if (first){setTimeout('first = false',10)}
}
|
|
#14
|
|||
|
|||
|
Mike,
I went offline for a couple of days, hence the delay; thanks! for the followup. I made a few more changes for 10Q.html as shown in the complete code below based on error detection with "HTML-Kit" from www.chami.com. see: http://www.download.com/HTML-Kit/300...4-4687625.html Two warnings from running "Check Code Using TIDY", however, could not be resolved: "Warning", "1","44","57","0","'<' + '/' + letter not allowed here" "Warning", "2","44","74","0","'<' + '/' + letter not allowed here" These are likely of minor significance, though. Thanks again! katydid Code:
<HTML>
<Head>
<Script type="text/javascript">
var URLstr = "http://www.sec.gov/cgi-bin/browse-edgar?type=10-Q%2FA&owner=include&action=getcompany&CIK="
var ticker = new Array('AA','AIG','AXP','BAC','C','CAT','DD','GIS','GE','GM','HD','HON','HPQ','IBM','INTC','JNJ','JPM','KO','MCD','MMM','MO','MRK','MSFT','PFE','PG','SBC','UTX','VZ','WMT','XOM')
var useWidth = screen.width-50;
var n = 0;
var pauseFlag = false;
var roll1 = "";
var first = true;
function pauseRoll(){
clearTimeout(roll1);
pauseFlag = true;
n--;
}
function continueRoll(){
pauseFlag = false;
rollFrame();
}
function rollFrame(){
clearTimeout(roll1);
if (!pauseFlag && !first)
{
if (n < 0){n = 0}
else if (n < (ticker.length-1)){n++}
else {n = 0}
roll1 = setTimeout("window.frames.secInfo.location.href = URLstr+ticker[n]",2000);
}
if (first){setTimeout('first = false',10)}
}
function setUp(){
document.getElementById('A').setAttribute('width',useWidth);
window.frames.secInfo.document.write("<font size='4'>Loading...</font>");
window.frames.secInfo.location.href = URLstr+ticker[0];
}
window.onload=setUp;
</Script>
<title></title>
</Head>
<Body>
<IFRAME name='secInfo'
id='A'
Src = ''
onload='rollFrame()'
height='510'
frameborder='yes' scrolling='yes'>
</IFRAME>
<br>
<form action=''>
<input type='button' id='pauseBtn' value='Pause' onclick='pauseRoll()'>
<input type='button' id='continueBtn' value='Continue' onclick='continueRoll()'>
</form>
</Body>
</HTML>
|
|
#15
|
|||
|
|||
|
katydid:
You are again, welcome. Forgive my wrong assumption. However, I'm not one to engage in this "validation," or "error checking," exercise. Recently, someone very astute, wrote in a thread, concerning "validation," that THIS site, this forum, when offered for "validation" returns more than 180 "errors." Hmm. That's all I need to know about "validation." Personally, if code WORKS, I don't look any further. I do understand that "validation" is very important to some, perhaps many. I bode no ill will toward them. Differences of opinion make the world go 'round. Good luck with the remainder of your project. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|