JavaScript - Tumblr Javascript On Refresh
Hi all,
I have a question (probably simple, as I'm a novice) for you. I'm finishing a tumblr theme in which I have my menu stick to the top of the window as I scroll down, and unstick when I scroll back up. It's working fine, except that if I scroll down and then refresh the page, the menu goes back to the middle of the page. Hard to explain, but you can see for yourself on my test page. Is there any way to make the menu stay on top through a refresh? My complete code is included below (apologies for its ugliness). Thanks in advance. Jon Code: <html> <head> <title>{Title}</title> <link rel="shortcut icon" href="{Favicon}"> <link rel="alternate" type="application/rss+xml" href="{RSS}"> {block:Description} <meta name="description" content="{MetaDescription}" /> {/block:Description} <meta name="color:Highlight" content="#ff0" /> <meta name="if:Show Portrait" content="0"/> <meta name="if:Show RSS Link" content="0"/> <meta name="if:Small Permalink" content="0"/> <meta name="font:Title" content="Futura"/> <meta name="font:Body" content="Courier New"/> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script type="text/javascript"> $(window).scroll(function(e){ $el = $('.fixed'); if ($(this).scrollTop() > 320 && $el.css('position') != 'fixed'){ $('.fixed').css({'position': 'fixed', 'top': '0px'}); } if ($(this).scrollTop() < 320 && $el.css('position') == 'fixed'){ $('.fixed').css({'position': 'relative', 'top': ''}); } }); </script> <style type="text/css"> body { background: #fff; margin-left: auto; margin-right: auto; width: 600px; font: 13px {font:Body}; color: #000; } body a { color: #000; } body a:hover { background-color: {color:Highlight}; text-decoration:none; } #desc { font-size: 12px; } .fixed { background-color: #fff; position:fixed; top: 310; width:100%; z-index:100; } #footer { text-align: center; font-size: 11px; color: #ccc; padding-top: 20px; padding-bottom: 20px; } #footer a { color: #ccc; } #header { {block:IfNotShowPortrait} top: 140px; {/block:IfNotShowPortrait} {block:IfShowPortrait} top: 100px; {/block:IfShowPortrait} text-align: center; position: relative; } #menu { width: 600px; border-bottom: 1px dashed; background: #fff; font-size: 11px; text-align: center; position: absolute; } #menu a { text-decoration: none; } #newer { float: right; margin-left: -60px; } #notes { color: #ccc; {block:IfNotSmallPermalink} border-bottom: 1px dashed; margin-bottom: 30px; {/block:IfNotSmallPermalink} {block:IfSmallPermalink} margin-top: 20px; margin-bottom: 45px; text-align: center; {/block:IfSmallPermalink} font-size: 11px; } #notes a { color: #ccc; {block:IfSmallPermalink} text-decoration: none; {/block:IfSmallPermalink} } #notes a:hover, #footer a:hover { color: #000; } #notes_page { margin-top: 30px; } #notes_page ol { list-style: none; padding: 0px; margin: 0px; width: 600px; } #notes_page li { padding: 2px; background-color: #fff; margin-top: 2px; } #older { float: left; margin-right: -60px; } #photo, #video { text-align: center; } #photo img { max-width: 600px; } #post_container { {block:IfNotShowPortrait} margin-top: 340px; {/block:IfNotShowPortrait} {block:IfShowPortrait} margin-top: 260px; {/block:IfShowPortrait} } #quote { font-size: 18px; } #title a { font: 36px {font:Title}; font-style: italic; letter-spacing: 10px; text-decoration: none; } {CustomCSS} </style> </head> <body> <div class="fixed"><p><div id="menu"> <div id="older"> {block:NextPage} <a href="{NextPage}">← Older</a> {/block:NextPage} </div> <a href="/">Home</a> / <a href="/archive">Archive</a> {block:IfShowRSSLink} / <a href="{RSS}">RSS</a> {/block:IfShowRSSLink} {block:HasPages} {block:Pages} / <a href="{URL}">{Label}</a>{/block:Pages} {/block:HasPages} {block:AskEnabled} / <a href="/ask">Ask</a>{/block:AskEnabled} {block:SubmissionsEnabled} / <a href="/submit">Submit</a>{/block:SubmissionsEnabled} <div id="newer"> {block:PreviousPage} <a href="{PreviousPage}">Newer →</a> {/block:PreviousPage} </div><p> </div></div> <div id="header"> {block:IfShowPortrait}<img src={PortraitURL-64}>{/block:IfShowPortrait}<p> <div id="title"><a href="/">{Title}</a></div><br> {block:Description}<div id="desc">{description}</div>{/block:Description}<p> </div><p> <div id="post_container"> {block:Posts} {block:Text} {block:Title}<a href="{Permalink}">{Title}</a>{/block:Title} {Body} {/block:Text} {block:Photo} <div id="photo">{LinkOpenTag}<img src="{PhotoURL-HighRes}" alt="{PhotoAlt}"/>{LinkCloseTag}</div> {block:Caption}{Caption}{/block:Caption} {/block:Photo} {block:Photoset} {Photoset-500} <div id="caption">{block:Caption}{Caption}{/block:Caption}</div> {/block:Photoset} {block:Quote} <div id="quote">"{Quote}"</div><p> {block:Source} ~ {Source}{/block:Source} {/block:Quote} {block:Link} <a href="{URL}" class="link" {Target}>{Name}</a> {block:Description}{Description}{/block:Description} {/block:Link} {block:Chat} {block:Title}<h3><a href="{Permalink}">{Title}</a></h3>{/block:Title} <ul class="chat"> {block:Lines} <li class="{Alt} user_{UserNumber}"> {block:Label} <span class="label">{Label}</span> {/block:Label} {Line} </li> {/block:Lines} </ul> {/block:Chat} {block:Video} <div id="video">{Video-500}</div> {block:Caption}{Caption}{/block:Caption} {/block:Video} {block:Audio} {AudioPlayerBlack} {block:Caption}{Caption}{/block:Caption} {/block:Audio} {block:Answer} <h3>{Asker} asked: {Question}</h3> {Answer} {/block:Answer} <div id="notes"> {block:IfSmallPermalink}<a href="{Permalink}">↵</a>{/block:IfSmallPermalink} {block:IfNotSmallPermalink} <p><br> {block:Date}<a href={Permalink}>{DayOfMonth} {ShortMonth} {Year}</a>{/block:Date}{/block:IfShowDate} {block:RebloggedFrom} / Reblogged from <a href="{ReblogParentURL}">{ReblogParentName}</a>{/block:RebloggedFrom} {block:HasTags} / {block:Tags}<a href={TagUrl}>{Tag}</a> {/block:Tags}{/block:HasTags} {/block:IfNotSmallPermalink} </div> {/block:Posts}</div> {block:PermalinkPage} <div id="notes_page"> {block:PostNotes} {PostNotes} {/block:PostNotes} </div> {/block:PermalinkPage} <div id="footer"> Theme by <a href="http://toxicjungle.co">Jon</a>. </div> </p> </body> </html> Similar TutorialsHello, my name is Paula an I am making a website where I have an image changing on my homepage each time it is reloaded. I found a code that lets me do this. This is the script: <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Set up the image files to be used. var theImages = new Array() // do not change this // To add more image files, continue with the // pattern below, adding to the array. theImages[0] = '1.gif' theImages[1] = '2.gif' theImages[2] = '3.gif' theImages[3] = '4.gif' var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } </script> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin showImage(); // End --> </script> It worked fine, with four images. The thing is I wanted to put up to 16 in it. So I tried ad up to 16 numbers with images but as soon as I put more than four, it would not work. Finally what I did was to copy four times the same numbers and then it worked (0-3 , four times)... so then I had many images shown randomly but the problem now is that the random is very uneven among the images. Meaning, I get variation among very few, and many time repeating one. This is what my script looks like now: <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Set up the image files to be used. var theImages = new Array() // do not change this // To add more image files, continue with the // pattern below, adding to the array. theImages[0]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/Alacenaconcajadegalletes-pgWShadow3.jpg' theImages[1]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/AltarinGasStation-pgSH.jpg' theImages[2]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/AltaroftheDeadwithEmbroideredTablecloth-pgSH.jpg' theImages[3]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/Altarsobreparedverde-pgSH.jpg' theImages[0]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/BricksandClotheslineSH-pg.jpg' theImages[1]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/Cocinaamarilla-pgSH.jpg' theImages[2]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/LatadeTecateconenchufes-pgSH.jpg' theImages[3]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/LedgewithTecates-wcSH.jpg' theImages[0]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/Mesaamarilla-pgSH-pg.jpg' theImages[1]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/MosaicwithPhotographofVictorianInterior-pgSH.jpg' theImages[2]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/Paredrojaconjualas-pg.jpg' theImages[3]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/red_cupboardSH.jpg' theImages[0]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/RoomwithLandscapeofBurgundy-pgSH.jpg' theImages[1]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/Cocinaamarilla-pgSH.jpg' theImages[2]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/YellowandRedPorch-wcSH.jpg' theImages[3]='http://elenacliment.tomosfactory.fr/userfiles/image/ImagesElena/ElenaPaintingsHome2/LedgewithTecates-wcSH.jpg' var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } // End --> </script> So my question is: How can I manage with this script to have all my images showing up equally when they change in refresh? I don not mind if they are not random, I also tried to remove the random property but could not manage either. Any ideas? Thank you so much, I really appreciate your help. Paula I'm finishing up an e-commerce website, and I can't quite figure out why the shopping cart feature is acting all screwy in Internet Explorer. It works fine in Firefox, but in IE, when you add a product to the cart it doesn't display the little pop-up notification, and when you click on the "my cart" at the top right the product quantities are incorrect about 70% of the time. For some reason IE keeps doubling the quantities; I think one of the scripts may be double refreshing the page I just can't figure out where. If anyone has any suggestions they would be much appreciated. The site I'm referring to is he www.tcatvs.com Thanks y'all! Also I'm using the jquery framework for much of the site. FF, Safari, Opera all execute this javascript code to refresh the page properly, but in IE version 8.0.6001.18904 the page doesn't seem to refresh on click of orange_refresh button. I have checked out a different version of IE8, don't recall exact version, but it did seem to work fine in that one, whatever version it was probably the latest now that I think of it. Check out code below any sug.'s could be helpful, though its probably a bug.. Code: <a href="javascript:document.location.reload();" onmouseover="window.status='Refresh'; return true" onmouseout="window.status='Page Refreshed'"><img src="image/orange_refresh.png" width="30" height="30" border="0" /></a> when I upload a new javascript file to the server and refresh the webpage, the webpage behaves as if the old script is on the server, this happens with IE and firefox, even if I shut the programs down and restart them, can anyone help? I am sorry if this is a stupid question. I have never really used javascript before. I found some code online that I tried to piece together so I might not even be going about this the right way. I want the background to take up 100% and resize with the browser. That works fine. I also want the text "welcome to the ahi life" stick to the bottom left hand corner and the enter button to stick to the bottom right. I would like these to resize with the browser as well. It all kind of works, except the first time you load the page the text and the button are much smaller than I would like them to be. If you refresh the page everything is correct. The url is http://www.ahiapparel.com/landing.html Code: <style> * { margin: 0; padding: 0; } #bg { position: fixed; top: 0; left: 0; } .bgwidth { width: 100%; } .bgheight { height: 100%; } #page-wrap { position:absolute; bottom:0; left:20px; width: 700px; margin: 50px auto;} #welcometext { position: fixed; bottom: 20px; left: 25px; } .welcometextwidth { width: 7%; } .welcometextheight { height: 7%; } #entertext { position: fixed; bottom: 20px; right: 25px; } .entertextwidth { width: 7%; } .entertextheight { height: 7%; } </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $(function funct1() { var theWindow = $(window), $bg = $("#bg"), aspectRatio = $bg.width() / $bg.height(); function resizeBg() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $bg .removeClass() .addClass('bgheight'); } else { $bg .removeClass() .addClass('bgwidth'); } } theWindow.resize(function() { resizeBg(); }).trigger("resize"); }); $(function funct2() { var theWindow = $(window), $welcometext = $("#welcometext"), aspectRatio = $welcometext.width() / $welcometext.height(); function resizewelcometext() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $welcometext .removeClass() .addClass('welcometextheight'); } else { $welcometext .removeClass() .addClass('welcometextwidth'); } } theWindow.resize(function() { resizewelcometext(); }).trigger("resize"); }); $(function funct3() { var theWindow = $(window), $entertext = $("#entertext"), aspectRatio = $entertext.width() / $entertext.height(); function resizeentertext() { if ( (theWindow.width() / theWindow.height()) < aspectRatio ) { $entertext .removeClass() .addClass('entertextheight'); } else { $entertext .removeClass() .addClass('entertextwidth'); } } theWindow.resize(function() { resizeentertext(); }).trigger("resize"); }); </script> My best guess is that either the functions or some of the variables are conflicting somehow, but I have tried just about everything to fix it. Any help would be much appreciated. Thanks! Hello Friends In my jsp,Struts project i am using the javascript calendar control for selecting the date and by using function calcage() i am calculating the age of the user but problem occurs when the page refreshes OR when user updated the other values such as name ,contact no. Then the value of the age is set as 0 in the textfield as 0 So can you please tell me why this problem occurs And please give me solution Thanks i'm working with a city select option, a hotel select option & an iframe. the hotel select option is populated depending on the chosen city which then updates the iframe src. this is all working fine. the trouble im having is that when the page is refreshed, normal f5 way, the hotel option changes whereas the city option & the iframe src remains the same?? this problem does not occur on a force refresh via control + f5 as then both select options & iframe src revert to their original state. I don't want the city option to change upon a normal page refresh. how do I go about this? below are the city, hotel select options & iframe Code: <form name="hotelslist" id="hotelslist"> <select id="cities" name="cities" onChange="hotel_list(hotelslist.cities.selectedIndex);loadHotel();"> <option value="Baddeck">Baddeck</option> <option value="Banff">Banff</option> </select> <select id="hotelnames" name="hotelnames" onChange="loadHotel();"> <option value="Inverary Resort, Baddeck">Inverary Resort, Baddeck</option> </select> </form> <iframe name="hotelframe" id="hotelframe" src="http://www.google.com" scrolling="no" width="660" height="1000" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0"> <p>Your browser does not support iframes.</p> </iframe> below is my javascript functions Code: function loadHotel() { var destURL = document.hotelslist.hotelnames.options[document.hotelslist.hotelnames.selectedIndex].value; window.frames["hotelframe"].location = destURL; } var i; function hotel_list(i){ var hotelslist = document.getElementById("hotelslist"); hotelslist.hotelnames.options.length=0; switch(i) { case 0: //Baddeck hotelslist.hotelnames.options[0] =new Option('Inverary Resort, Baddeck','http://www.test0.com'); break; case 1: //Banff hotelslist.hotelnames.options[0] =new Option('Banff Caribou Lodge & Spa','http://www.test1.com'); hotelslist.hotelnames.options[1] =new Option('Banff Ptarmigan Inn','http://www.test2.com'); hotelslist.hotelnames.options[2] =new Option('Banff Rocky Mountain Resort','http://www.test3.com'); hotelslist.hotelnames.options[3] =new Option('The Rimrock Resort','http://www.test4.com'); hotelslist.hotelnames.options[4] =new Option('Fairmont Banff Springs','http://www.test5.com/'); break; } } can some one please advise on a cross browser solution? thanks in advance. Omar. I have a php file lets say file1.php, that printing a variable, its dynamic numbers output that already always increasing, like private message numbers that coming or others : PHP Code: <?php echo $variable ?> i want to put that variable output, in another files page title, lets say file2.php or file3.html, in the front of the another files page titles, and auto refresh every x seconds, maybe like this : Quote: (1) - another text in the page title after x seconds, get a private message Quote: (2) - another text in the page title after another x seconds, get another private message Quote: (3) - another text in the page title or its ok if just like this, only the variable, without the another text in the page title Quote: (1) please share your knowledge to make it, maybe using javascript, jquery or others Hi, I have the below code: Code: <script type="text/javascript"> function loadQuickMessageCheck(File,ID){ var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; eucalyptus = setInterval(function(){loadQuickMessageCheck(File,ID)},20000); } } xmlhttp.open("POST",File,true); xmlhttp.send(); } </script> But I am overloading the server and crashing it. I've googled the issue and have found people with similar problems who talk about the need to cancel the last refresh request before they send the next refresh. I even found this nice piece of code which worked for someone else. Quote: try{window.clearTimeout(tRefresh)} catch(err) {} tRefresh = setInterval(setContext, varInterval*60*1000); } I am not sure if this is the solution that I am looking for but if it is all my attempts at applying this code has been a bit of a disaster. Hello. Been searching all night for a way to do this, so thanks in advance for any help forthcoming. I'd like to be able to create a list of post titles that share the same tag in tumblr (rather than a list of tags). Tumblr allows you to filter your posts by tag by typing in a url, but this brings up a full page of posts, and I'd just like a list of the titles that I can then use as a menu. Hope this all makes sense. I'd imagine this is fairly simple as the capability to filter by tag already exists, but I cannot for the life of me work out how to do it. Thanks again. Hi, I am somewhat new to HTML, AJAX, and CSS. I'm wish to implement something similar to what Tumblr does on their front page where you click on the bottom footer bar, and the page horizontally shifts up keeping part of the original page (specifically, the email sign up) visible while exposing more content. I know the simplest is to have the entire content on the page and just "hide" and "show" the interested components "on click" of the bottom footer bar div-tag. But I like the sliding animation. Does YUI or JQuery provide the ability to do the animation? Or is this even a Javascript related functionality - ie should I look at HTML5 or CSS? Thanks Jack Hi I need some help. I have a link that opens in a new window which allows the user to perform an update to a record. On submit I want it to obviously update (which it does), then close the page and update the main page (where we opened the link from initially). I seem to have this working using an function which is called off the submit button using onclick........the function is: <script type="text/javascript"> function windowclose() { window.opener.location.href = window.opener.location.href; window.close() } </script> Now, the update happens as I say, and the page closes, and the main page looks like it refreshes but the update is not reflected....if I hit f5 the update appears. Is it to do with the speed of writing to the database and updating the screen? I have also been playing around with trying to add a settimeout to add a delay between update and close/refresh but couldnt get it to work. Any help would be appreciated. Cheers! Well first off all I would appricate any help that you could give me because I've been looking all over the internet for the solution without any result. So off to my problem, I made this text-based online game and let's say the user does a crime, he did this crime 17:04:30 and has to wait till 17:06:30 before he can do a crime again (this is printed in the MySQL database). Getting the value from the database and changing it into the right format mm:ss is no problem. The problem comes to when its about refreshing... I've tried meta refresh and javascript location.refresh with good results, i sat the timer to 1 sec and it refreshed. The problem comes to when it refresh the mouse cursor and the tab (in firefox and chrome) gets that look, like when u refresh a page normally u can see an hourglass and all that. Is there anyway to disable that? And i think it really slows the browser down after a while (because after like 30 min or more firefox used 600 mb of my RAM). So yeah here's my Iframe code: Code: print <<<ENDHTML <IFrame Src= "right_timer.php" Scrolling=No Frameborder=0 Marginheight=0 Marginwidth=0 Width=100% Height=160> <p>Your browser does not support iframes.</p> </iframe> Also here's the right_timer.php: Code: <?php include("config.php"); $dbres = mysql_query("SELECT *,UNIX_TIMESTAMP(`crime`) AS `crime` FROM `users` WHERE `login`='{$_SESSION['login']}'"); $data = mysql_fetch_object($dbres); if(! check_login()) { print"<link rel=stylesheet type=text/css href=style.css>";exit; } if ($data->status == dead) { print"<link rel=stylesheet type=text/css href=style.css>";exit; } ?> <html> <head> <meta http-equiv="refresh" content="1"> </head> <body> <?php $dbres = mysql_query("SELECT * FROM `users` WHERE `activated`='1'"); $users= mysql_num_rows($dbres); $dbres = mysql_query("SELECT * FROM `users` WHERE `status`='alive' AND `activated`='1'"); $levend = mysql_num_rows($dbres); $dbres = mysql_query("SELECT * FROM `users` WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(`online`) < 300"); $online = mysql_num_rows($dbres); $dbres = mysql_query("SELECT * FROM `users`"); while($blah = mysql_fetch_object($dbres)){ $time = time(); $crime = gmdate('i:s',($data->crime - $time)); if (($data->crime - $time) < 0) { $crime = Now; } } print <<<ENDHTML <tr><td>Crime {$crime}</td></tr> ENDHTML; ?> </body> </html> I am trying to submit a hidden text area from a WYSIWYG editor. Its submitting the subject line which is a standard text input but its not submitting the text area. I can only think its because there are html tags in the submitted data. Is there a way to compensate for this or will I have to give up trying. hi i have a table with some document.write statements inside that write inside the cells. i need to refresh the table from a function so the statements will execute again. but i only want the table to refresh not the whole page document.location.reload() this does the page but can i put the tables id in the brackets or something. thanks i have a page named pck_rates.php which contains a form that go to the page update_pck_rates.php when i press updade data button in the second page i want the first page to be refreshed to show the new data's. i want to know if i can set a name to the page pck_rates.php and after the update query in the second page i will refresh the pck_rates.php page using this name?? i don't know what is the function and how to make this idea. can anyone help me please Is there a way to call a javascript function in a meta refresh statement? I'm refreshing my page but if I have data in my fields I don't want to loose them. If I can call using a JS function then in that function I can call the Submit function and save my data in the called script. My syntax below doesn't fire the JS function: PHP Code: <meta http-equiv="refresh" content="30;url=javascript:auto_refresh();"> Hi Frnds, I have faced some problem i.e I have 2 jsp pages.In that I want to go one jsp to another jsp.In 2nd jsp i can show my captcha code,but unfortunately it is not visible first page is reloaded in IE6.Once you refresh the page it's visible in IE6.So please help me to avoid this problem. Thanks, I need help with a javascript refresh button. I'm having trouble linking the feed fetcher section to the refresh button section. I think code lines 81 through 87 are the problem. [code] // create table view data object var data = []; var xhr = Ti.Network.createHTTPClient(); xhr.open("GET","http://rss.news.yahoo.com/rss/business"); xhr.onload = function() { try { var doc = this.responseXML.documentElement; var items = doc.getElementsByTagName("item"); var x = 0; var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue; for (var c=0;c<items.length;c++) { var item = items.item(c); var thumbnails = item.getElementsByTagName("media:thumbnail"); var media; if (thumbnails && thumbnails.length > 0) { media = thumbnails.item(0).getAttribute("url"); } else { media="blue.png"; } var title = item.getElementsByTagName("title").item(0).text; var row = Ti.UI.createTableViewRow({height:80}); var label = Ti.UI.createLabel({ text:title, left:72, top:5, bottom:5, right:5 }); row.add(label); var img; if (Titanium.Platform.name == 'android') { // iphone moved to a single image property - android needs to do the same img = Ti.UI.createImageView({ url:media, left:5, height:60, width:60 }); } else { img = Ti.UI.createImageView({ image:media, left:5, height:60, width:60 }); } row.add(img); data[x++] = row; row.url = item.getElementsByTagName("link").item(0).text; } var tableview = Titanium.UI.createTableView({data:data}); Titanium.UI.currentWindow.add(tableview); tableview.addEventListener('click',function(e) { var d=Titanium.Platform.openURL(e.row.url); }); // START REFRESH code var refresh = Titanium.UI.createButton({ systemButton:Titanium.UI.iPhone.SystemButton.REFRESH }); refresh.addEventListener('click', function() { tableview.Data([]); setTimeout(function() { Data(); },1000); }); if (Ti.Platform.name == 'iPhone OS') { win2.rightNavButton = refresh; } else { refresh.top = 5; refresh.title = "Refresh"; refresh.width = 200; tableview.top = 60; Titanium.UI.currentWindow.add(refresh); } Data(); //END REFRESH code } catch(E) { alert(E); } }; xhr.send(); [code] Code: var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects="" var rootdomain="http://"+window.location.hostname var bustcacheparameter="" function ThinkHabbo(url, containerid){ var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) document.getElementById(containerid).innerHTML=page_request.responseText } function loadobjs(){ if (!document.getElementById) return for (i=0; i<arguments.length; i++){ var file=arguments[i] var fileref="" if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding if (file.indexOf(".js")!=-1){ //If object is a js file fileref=document.createElement('script') fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", file); } else if (file.indexOf(".css")!=-1){ //If object is a css file fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", file); } } if (fileref!=""){ document.getElementsByTagName("head").item(0).appendChild(fileref) loadedobjects+=file+" " //Remember this object as being already added to page } } } Is there any chance i can add a refresh timer to this? |