JavaScript - Actively Change/update Content In A Specific Part Of A Page
I am current building an information database for the company I work at...basically just a place for employees to get information and answers from. It is all hosted on a local server and I can only use javascript, html, and css. Ive got everything made there is just one thing i want to add to it. basically an "alerts and updates" page that only some people can edit without having to know html so if im not there they can post important updates. no computers have access to the internet so I did try some rich text editors but none of them worked. the lay out I'm going for is kind of like this.
------------------------------------ Alerts and Updates Click on links to show updates: update 1 * update 2 * update 3 * update 4 stuff goes in the update [edit button] ------------------------------------- you click edit it prompts you to login, bring up something to edit the text in that specific update you hit submit and it changes the info that was on there. The update links are linked to a script i wrote that just display the info below so when the page loads you see whats in update 1 then you click update and it changes the content to the next one. i dont know if there is any way to do this in javascript and html. any help or a good direction to start would be great...thanks. Similar TutorialsHi, I have this PHP code that shows the amount of minutes and seconds to a certain date. Somehow I want to update this code every second so that it looks like it's counting down. Anyone who has any good pointers how to do this? Thank you in advance. The project I am working on involves a flash piece that communicates with a iframe. Currently the flash piece just calls on javascript functions. I want the buttons in the flash piece to be able to change the src of the iframe. PHP Code: <script type="text/javascript"> document.getElementById('video').setAttribute('src',address2); function closeVideo() { document.getElementById('video').style.height='0px'; return false; document.getElementById('video').setAttribute('src', address2); } function openVideo() { document.getElementById('video').style.height='391px'; return false; document.getElementById('video').setAttribute('src', address); } </script> So the way the code works now is when the page loads it sets the iframe with the id of 'video' to the variable address2 which it pulls from an XML file. In the flash piece when a button is hit, it calls openVideo() which "opens" the iframe and I want it to change the contents to address. This does not work though. It opens the frame but will not change the src. I've tried a bunch of different things now such as make the flash target the iframe using navigateToURL(request1, 'video'); but in Firefox and IE is opens it stills as if I had _blank in there. It does strangely work in Safari. Any ideas how to get this to work? I'm new to javascript so it could be something basic I'm overlooking Code is triggered on the following page when mouse position leaves a profile link while logged in: http://www.veinsfetiche.com/forums/ Code: <script type="text/javascript"> // <![CDATA[ // show the popup function show_popup(UserID) { if(http_getuser) { //get user data and show popup sendRequest(UserID); } } // hide the popup function close_popup() { document.getElementById('popup').style.display='none'; } // Make the request function createRequestObject() { if(window.XMLHttpRequest){ ro = new XMLHttpRequest(); } else if(window.ActiveXObject) { ro = new ActiveXObject("Msxml2.XMLHTTP"); if(!ro) { ro = new ActiveXObject("Microsoft.XMLHTTP"); } } return ro; } //Create Request Variables var http_getuser = createRequestObject(); //Send Request for user info function sendRequest(UserID) { var userinfo_url = '{AJAX_USERINFO_PATH}'; http_getuser.open('get', userinfo_url.replace('USERID', UserID)); http_getuser.onreadystatechange = handleResponse; http_getuser.send(null); } // fill in the response function handleResponse() { if(http_getuser.readyState == 4 ){ var xmlDoc = http_getuser.responseXML; if(xmlDoc.hasChildNodes()) { document.getElementById('ajax_username').innerHTML = xmlDoc.getElementsByTagName('username')[0].firstChild.nodeValue; document.getElementById('ajax_registert').innerHTML = xmlDoc.getElementsByTagName('regdate')[0].firstChild.nodeValue; document.getElementById('ajax_posts').innerHTML = xmlDoc.getElementsByTagName('posts')[0].firstChild.nodeValue; document.getElementById('ajax_website').innerHTML = xmlDoc.getElementsByTagName('website')[0].firstChild.nodeValue; document.getElementById('ajax_from').innerHTML = xmlDoc.getElementsByTagName('from')[0].firstChild.nodeValue; document.getElementById('ajax_last_visit').innerHTML = xmlDoc.getElementsByTagName('lastvisit')[0].firstChild.nodeValue; document.getElementById('ajax_rank').innerHTML = xmlDoc.getElementsByTagName('rank')[0].firstChild.nodeValue; document.getElementById('ajax_avatar').innerHTML = xmlDoc.getElementsByTagName('avatar')[0].firstChild.nodeValue; //document.getElementById('ajax_add').innerHTML = xmlDoc.getElementsByTagName('add')[0].firstChild.nodeValue; //Apply style which makes profile info visible document.getElementById('popup').style.display='block'; //Get height of popup var getRefById = function() {return null;}; if(document.getElementById) { getRefById = function(i) {return document.getElementById(i);}; } else if(document.all) { getRefById = function(i) {return document.all[i] || null;}; } var d = getRefById('popup'), h = '0px', o; if(d) { if((o = document.defaultView) && o.getComputedStyle) { h = o.getComputedStyle(d, null).height; } else if('number' == typeof d.offsetHeight) { h = d.offsetHeight + 'px'; } } // 'h' should now contain the height of 'myDiv', or 0px //alert(h); //make room for popup document.getElementById('test').style.height= h; } } } // set popup to mouse possition function set_div_to_mouse(e) { //Make x and y cord vars var docX, docY; //get page info if(e) { if(typeof(e.pageX) == 'number') { docX = e.pageX; docY = e.pageY;} else {docX = e.clientX; docY = e.clientY;} //vert } else { e = window.event; docX = e.clientX; docY = e.clientY; if(document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) { docX += document.documentElement.scrollLeft; docY += document.documentElement.scrollTop; } else if(document.body && (document.body.scrollTop || document.body.scrollLeft)) { docX += document.body.scrollLeft; docY += document.body.scrollTop; } } //hor if (docX > document.body.offsetWidth - 400) { document.getElementById('popup').style.left = (docX - 350) + "px"; } else { document.getElementById('popup').style.left = (docX - 5) + "px"; } document.getElementById('popup').style.top = (docY + 30) + "px"; } //document.onmousemove = set_div_to_mouse; // ]]> </script> <div id="test"> <div class="forabg" id="popup" style="width: 90%;"> <div class="inner"> <span class="corners-top"><span></span></span> <ul class="topiclist fullwidth"> <li class="header"><dl><dt>{L_READ_PROFILE}</dt></dl></li> </ul> <ul class="topiclist forums"> <li><dl> <dd style="width:100%"> <table> <tr> <td><div id="ajax_avatar"></div></td> <td><strong>{L_USERNAME}:</strong> <span id="ajax_username"></span><br /> <strong>{L_TOTAL_POSTS}:</strong> <span id="ajax_posts"></span><br /> <strong>{L_SORT_RANK}:</strong> <span id="ajax_rank"></span><br /> <strong>{L_JOINED}:</strong> <span id="ajax_registert"></span><br /> <strong>{L_LAST_VISIT}:</strong> <span id="ajax_last_visit"></span><br /> <strong>{L_LOCATION}:</strong> <span id="ajax_from"></span><br /> <strong>{L_WEBSITE}:</strong> <span id="ajax_website"></span><br/> <span id="ajax_add"></span> </tr> </table> <br/ style="clear: both;"> </dd> </dl></li> </ul> <span class="corners-bottom"><span></span></span> </div> </div> </div> When my code hits line 80, the height of a div tag is increased to make room for expanding content, so that the new content does not overlap already existing content. When the div tag's height increases, this increases the overall page height. When the page height increases, then the scroll bar stays in the same place, but the page position changes in the browser. Is there anyway to prevent the viewer's position from changing when room is made for the expanding content? Hi, The Problem I am trying to create a Google Translate widget on my webpage, with just one language pair, Latin to English. Unfortunately the Google Translate AJAX API only supports a subset of all languages available, and Latin is not included. However, Latin IS included on the Google Translate website. Apparently languages that are in beta are available there, via a different server, while only fully released languages are available via the AJAX Translate API. My Attempts at Solutions a) I wrote a script that generated the XMLHttpRequest() call to the server the Google Translate website uses, but it always returned a '0' status code. I have since found out that this is normal, as these kinds of calls can only be made between pages on the same server. b) I then wrote a script that created a popup, and used the baseURL+params for the URL, , and this produced a pop-up window containing the translation result. However, as that page came from a different server to the server containing the script, I could not access the results on it. The code for that is he Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function popUp(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,locationbar.visible=false,status=0,menubar=1,resizable=0,width=500,height=400,left = 710,top = 400');"); window.focus(); } // End --> </script> </head> <body> <form> <input type=button value="Open the Popup Window" onClick="javascript:popUp('http://translate.google.com/translate_a/t?client=t&q=vicecomes&sl=la&tl=en&pc=0')"> </form> </body> </html> c) So, in final desperation I wrote a small script with an IFrame in it that shows the Google Translate webpage, using this code: Code: <iframe name="frame1" src="http://translate.google.com/?sl=la&tl=en#la|en|" frameborder="0" scrolling="auto" style="width:100%;height:280px;"></iframe> The result can be seen here (click on the Latin-Help tab): http://www.blanshard.org/ Not too bad. Now I would like to just to tidy this up (until Latin comes out of beta and is moved to the Google Translate AJAX API server) I would like to move the Google Translate page up a few px so that the top menu does not show, and disable the scrollbars, so I am just framing the Translation box and result area. It appears that the top-left corner of the called page always aligns with the top-left corner of the IFrame, but I want to add offsets. Is it possible to offset the called page anywhere within the IFrame so I can frame just the part I want? Thanks for any help, Wibs I've got an idea for simplifying my code and avoid a bunch of switch functions but don't know how, though I assume it's possible. How do I write a function to change/insert only part of an img src? in other words something along the lines of if url contains: "/folder1/folder3/"; change this to: "/folder1/ folder2 /folder3/"; http://phplist.xxmn.com/menu.html When the mouse hover on the navigation (cpanel). it shows the corresponding content under it. but i can't click the link in it. is there a way to get it.i know it will be using setTimeout. but i don't know how to do. thank you. when i change the top value small.but under IE7 and IE6.i still can't click the link in the showing content. Hello. My goal is to load the JS for a specific element before displaying that element. I integrated a third part script, and it works well. I set the timer he The JS is in my heading as <script type="text/javascript" src="countdownpro.js"></script> About mid-body I have: <span id="countdown1">2010-07-20 00:00:00 GMT+00:00</span> which allows for the setting of a target date to countdown to. When the page first loads it shows the above long format target time, until the js/meta tags kick in to modify it to just show the actual countdown as 00:00:00. I have attached countdownpro.js to this post. I tried shifting the function CD_Init() to the top of the script, and also appended it inline with the .html. I tried setting the big external script to "defer", but neither arrangement worked. I also tried placing the src file right at the top. I appreciate your help. Hello all, This may be a question more appropriate for the PHP section. How do you get javascript to change on a database action. Ok tough to explain, but for instance in gmail you receive instant messages when someone else hits enter and sends it. How do you get a change on your screen when they make a change on their client. -Questionable is there a way to set the meta description to x amount of charictars from the content of a div in the body? i was going to start toying with this but i though i would jump on here and ask the experts to see if it can actually be done first. thanks!!! Hello, I'd like to know how do this with javascript: 1. <a id="id_a" href="#table">Go to the middle of the page"</a> When I click at this link I go to that table. I'd like to "go" to this table with javascript. Can you help me? Thank you so much! Hi For our new site we need to regularly update part of page. What solutions are there for this purpose?? I have a slideshow on the "Projects" page. The javascript is external. There's a link on the homepage that when clicked needs to open the Projects page with the appropriate slide loaded. How do I do that? Here's the code I have for the slideshow: Code: var prev = document.getElementById('prev'); var next = document.getElementById('next'); var current = 0; function prevPic() { clearInterval(interval); if(current > 0) { current--; if(current == 0) { document.getElementById('next').src = "images/right_arrow.jpg"; document.getElementById('prev').src = "images/left_arrow_off.jpg"; } else { document.getElementById('next').src = "images/right_arrow.jpg"; document.getElementById('prev').src = "images/left_arrow.jpg"; } update(); } } function nextPic() { clearInterval(interval); if(current < slides.length - 1) { current++; if(current == slides.length - 1) { document.getElementById('next').src = "images/right_arrow_off.jpg"; document.getElementById('prev').src = "images/left_arrow.jpg"; } else { document.getElementById('next').src = "images/right_arrow.jpg"; document.getElementById('prev').src = "images/left_arrow.jpg"; } update(); } } function update() { var pic = slides[current]; document.getElementById('project_title').innerHTML = pic.title; document.getElementById('project_image').src = "images/slides/" + pic.image; document.getElementById('project_location').innerHTML = "<span>Location:</span> " + pic.location; document.getElementById('project_operation').innerHTML = "<span>Commercial Operation:</span> " + pic.commercial_operation; document.getElementById('counter').innerHTML = (current + 1) + " of " + slides.length; if(pic.link) { document.getElementById('project_link').style.display = "block"; document.getElementById('project_href').href = pic.link; } else { document.getElementById('project_link').style.display = "none"; } } //preload slides var images = []; for(i in slides) { var img = new Image(); img.src = "images/slides/" + slides[i].image; images.push(img); } I want a code that changes text (of maybe a div) after 10 seconds. So like i could have some text and a link on my page then after 10 seconds it will change to something else and i can make it change to as many things as i want. Then when it goes threw them all it starts over. THANKS right now i have a webpage that has a <div> with an id of "content". in that div I have a list of anchors. each list item displays data that is pulled from a mysql database. currently I have it set so that when the user clicks an anchor, a URL parameter is passed, which lets the next page populate from the database. however, i really need to make it so that everything stays on the same page; everything happens within the "content" div. how do i do this without passing a url parameter though? so far i've written down: 1. click link 2. call function to empty #content div 3. load in fragment of next page into #content div 4. ??? populate fragment with database info, the row chosen by what link was clicked ??? i'm using jquery and php. so far i've figured out: Code: $('.linkClass').bind('click',callNextPage()); //step 1 function callNextPage(){ $('#content').empty(); //step 2 $('#content').load(nextPage.php #fragmentId); //step3 //step 4 ?? pass in url parameter? or store a GET variable based on which link was clicked? return false; } any ideas? I have a div that changes background on click. Example: <script type="text/javascript"> function changeBackground(strURL) { document.getElementById('about').style.backgroundImage="url("+strURL+")"; } </script> <body> <div id="about"> <a href="#about" onClick="changeBackground('mainbackground.jpg');">text</a> <a href="#about" onClick="changeBackground('background2.jpg');">text</a> </div> This part works just fine so no issues. However, I have content on the mainbackground.jpg that is getting transferred over to the other backgrounds as well. I would like each background to have its own paragraph content. I do not want to embed the info into the images for SEO reasons. Any ideas on how to do this? Thanks! I have a div that changes background on click. Example: <script type="text/javascript"> function changeBackground(strURL) { document.getElementById('about').style.backgroundImage="url("+strURL+")"; } </script> <body> <div id="about"> <a href="#about" onClick="changeBackground('mainbackground.jpg');">text</a> <a href="#about" onClick="changeBackground('background2.jpg');">text</a> </div> This part works just fine so no issues. However, I have content on the mainbackground.jpg that is getting transferred over to the other backgrounds as well. I would like each background to have its own paragraph content. I do not want to embed the info into the images for SEO reasons. Any ideas on how to do this? Thanks! HI every one I want to change a div content in my page via javascript , the problem is the index.php file is coded and I can't read it , but I could execute some JavaScript codes from somewhere else . The problem is that the <div> is in the lowest side of the page and my javascript code is above it , so The javascript code runs first and It couldn't find the div because it's not loaded yet . my javascript code is something like this : <script> document.getElementById("test").innerHTML= "ddd"; </script> <div id="test">dude</div> in the example above , it's not working But if I insert the JavaScript below the <div> it's working . How can I run it in this example ? If the javascript code is above the <div> , how can I change the div's content ? Thanks hi all, I really need help with this topic. I have to use onMouseOver to change the content of an iframe. I'm trying to use an array but I'm confused and I'm not really sure if what I'm doing is correct and it doesnt work. I will appreciate your help and understanding. Thanks a lot! here is part of my code.. var frame=new Array(6); frame[0]="page1.html"; frame[1]="page2.html"; frame[2]="page3.html"; frame[3]="page4.html"; frame[4]="page5.html"; frame[5]="page6.html"; var j=0; function nextFrame() { if (j < 5) { j++; document.getElementById(frame).contentDocument=frame[j]; } return; } <span onMouseOver="nextFrame()" > <img name="upperImage" src="something.jpg" width=350 height=250 /></span> <iframe id="frame1" name="frame1" src="" width=350 height=250 frameborder="0"> </iframe> Please let me know if at least I'm in the right track. Thanks |