Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About paulclift

  • Rank
  1. Javascript: show/hide div on linked page

    @justsomeguy Thanks for your response. I am not particularly knowledgable with JS .... could you describe your solution in a little more detail please?
  2. I am displaying data from one page in another page in the following way: <script> $(document).ready(function(){ $( "#2017" ).load( "data.html .2017" ); $( "#2016" ).load( "data.html .2016" ); }); </script> <div id="2017"></div> <div id="2016"></div> ...BUT I also need to be able to hide (onload) certain div classes from within the linked file... <script> $(document).ready(function(){ $('.private-files').hide(); }); </script> I know that the code above will hide divs by class if they are contained in the main page, but how can I make it so that divs of class 'private-files' in 'data.html' will also be hidden?
  3. Update content on iframe inside iframe

    Thanks justsomeguy, but this seems to be something which is in development and does not quite suit my needs in this specific case..
  4. Hey all, I have a language switch on a website which updates the displayed language in the main iframe. However, I am also using fancy box, which pops up out of the iframe, and is therefore an iframe within an iframe. I change the language to be displayed with the following code: function setlang(lang) { var i; var len; var list; var ifr = document.getElementById('mainframe'); var cw = (ifr.contentWindow || ifr.contentDocument); list = cw.document.getElementsByClassName('langdiv'); for (i=0, len=list.length ; i<len ; i++){ list.style.display = 'none'; } list = cw.document.getElementsByClassName(lang); for (i=0, len=list.length ; i<len ; i++){ list.style.display = 'inline-block'; } } .....and here is the HTML: <input id="EN" name="view" type="radio" onclick="setlang('EN'); sessionStorage.setItem('language', 'EN');"> <input id="DE" name="view" type="radio" onclick="setlang('DE'); sessionStorage.setItem('language', 'DE');"> <input id="FR" name="view" type="radio" onclick="setlang('FR'); sessionStorage.setItem('language', 'FR');"> Could someone please help me make this work whereby the iframe is not necessarily called 'mainframe' but is simply *any* iframe that has multiple languages? I suspect that this will necessitate converting most of my vars into arrays, something which I am not really confident about doing on my own. Thanks! The website in question is: www.neuverband.ch
  5. Use current date to move divs

    I was wondering if someone could come up with a way of using the current date to set the position of a div. I would like to apply such a process to this page: http://www.paulclift.net/news.html The object in question which I would like to move automatically up and down, so that it is in the appropriate place relative to the other items on the page, is the three HR lines with past/future written above & below it. There must be a way to do this - not having to constantly move this object, and others like it on other pages, would be a huge time-saver! Please help if you have any ideas. Thanks. Here is the code I have so far: //first, get today's date Date.prototype.yyyymmdd = function() { var yyyy = this.getFullYear().toString(); var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based var dd = this.getDate().toString(); return yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]); }; d = new Date();//next, set the 'seperator' id to today's date document.getElementById("seperator").setAttribute("id", d.yyyymmdd());//next, find divs with a date for an ID function sortDivs(div) { var elems = document.getElementsByClassName("date");// Sort array numerically elems.sort(function(a, b) { return a.id.split()[1] - b.id.split()[1]; });// finally, move elements to sorted order while (iLen--) div.insertBefore(a[iLen], div.firstChild); } <div id="news-content"></div><div id="separator" class="date">THIS IS MY SEPARATOR DIV/div><div id="20150523" class="date">CONTENT<div>MORE CONTENT</div></div><div id="20150524" class="date">CONTENT<div>MORE CONTENT</div></div><div id="20150525" class="date">CONTENT<div>MORE CONTENT</div></div>
  6. Show/hide divs inside inline frame from main page

    Just realised I never thanked you for this, justsomeguy - so thanks very much - your code really helped me out a lot!
  7. Show/hide divs inside inline frame from main page

    AHHHH yes, the '.' before 'contentWindow' ..... now we're in business
  8. Show/hide divs inside inline frame from main page

    I think perhaps that it would be better just to switch to an 'if' and 'else' .... your thoughts?
  9. Show/hide divs inside inline frame from main page

    With this code: <script> function setlanguage(language, n1, n2, n3) { var ShowLang = document.getElementById('mainframe').contentWindow.document.getElementsByClassName(language); for(var i = 0; i < ShowLang.length; i++) { ShowLang.style.display='none'; } var HideLang = document.getElementById('mainframe')contentWindow.document.getElementsByClassName(n1); for(var i = 0; i < HideLang.length; i++) { HideLang.style.display='none'; } } </script> ...I get the error message "SyntaxError: Expected an identifier but found 'contentWindow' instead" for the line: var HideLang = document.getElementById('mainframe')contentWindow.document.getElementsByClassName(n1);
  10. Show/hide divs inside inline frame from main page

    hmmm it seems that having two 'for's or two 'var's in my function is causing the problem...... I thought that that was okay?
  11. Show/hide divs inside inline frame from main page

    Thanks for the help...... that's good for a start, but I noticed that if I replace 'n1' with, for example 'IT', those divs still don't disappear from the page loaded inside the iframe..... I cannot understand why that part is not working!
  12. Show/hide divs inside inline frame from main page

    I noticed that other people seemed to have gotten the above javascript running with a 'getElementById' rather than by ClassName....... but surely that would not stop it from working.... Also, I know that an 'if' and 'else' inside the function would be rather more elegant....
  13. Show/hide divs inside inline frame from main page

    So the following seems promising, but is not working for me for the moment: <script> function setlanguage(language, n1, n2, n3) { var ShowLang = document.getElementById('iframe').contentWindow.document.getElementsByClassName(language); for(var i = 0; i < ShowLang.length; i++) { ShowLang.style.display="block"; } var HideLang = document.getElementById('iframe')contentWindow.document.getElementsByClassName(n1, n2, n3); for(var i = 0; i < HideLang.length; i++) { HideLang.style.display="none"; } } </script> <body> <input id="english" type="radio" checked onclick="setlanguage('EN', 'DE', 'FR', 'IT')"> <input id="deutsch" type="radio" onclick="setlanguage('DE', 'EN', 'FR', 'IT')"> <input id="francais" type="radio" onclick="setlanguage('FR', 'EN, 'DE', 'IT')"> <input id="italiano" type="radio" onclick="setlanguage('IT', 'EN', 'DE', 'FR')"> <div id="iframe"> <iframe src="home.html"></iframe> </div> </body> (it goes without saying that the "home.html" document is full of divs with class "EN", "DE" etc....) Perhaps I need to reload the iframe page after changing the display value in the parent document?
  14. Show/hide divs inside inline frame from main page

    Hmmm is that right? I was looking for other instances of this and got the impression that it was possible..... my other thought was to use sessionStorage and pass the value to the iframe documents, but if you could simply control the iframe pages from the index.html it would be much cleaner....
  15. I am trying to use a simple radio button in my main page to show and hide divs by class which are inside an iframe. Here are the relevant snippets of code: In the "index.html" : <head> <script> function setlanguage(language) { ..........will save myself the embarrassment of showing you my attempts at coding this................. } </script> </head> <body> <input id="english" type="radio" checked onclick="setlanguage('EN')"> <input id="deutsch" type="radio" onclick="setlanguage('DE')"> <input id="francais" type="radio" onclick="setlanguage('FR')"> <input id="italiano" type="radio" onclick="setlanguage('IT')"> <iframe src="home.html"></iframe> </body> Example from "inside-the-iframe.html" : <div class="EN">Hello world</div> <div class="DE">Guten Tag</div> <div class="FR">Bonjour</div> <div class="IT">Ciao Rigazzi</div> Should be dead easy for you guys... please help!