www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 06-30-2004, 12:25 PM
    ::bluemoth:: ::bluemoth:: is offline
    Registered User
     
    Join Date: Jul 2003
    Posts: 10
    Exclamation Open Window + iFrame Anchor

    I've got a popup html page called june.html with an iframe called list, which contains anchors 01 - 30.

    I'm using the following to open june.html, but cannot link to anchor 30, or any other anchors:
    Code:
    <a href="events/june.html#30" target="list" onclick="NewWindow(this.href,'June','456','300','no','center');return false" class=event>30</a>


    The function for the above is as follows:
    Code:
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);}

    Any help would be really appreciated, as this seems impossible.
    __________________
    ::bluemoth::
    Reply With Quote
      #2  
    Old 06-30-2004, 06:37 PM
    Mr J Mr J is offline
    Registered User
     
    Join Date: Apr 2003
    Location: UK
    Posts: 2,203
    It is possible but you only mention the page loading into the popup window, what about the page loading into the Iframe?
    Reply With Quote
      #3  
    Old 07-01-2004, 05:05 AM
    Kor's Avatar
    Kor Kor is offline
    Red Devil Moderator
     
    Join Date: Dec 2003
    Location: Bucharest, ROMANIA
    Posts: 11,522
    ...return false prevents the #name positioning... maybe you must use:

    <a href ="javascript:void(NewWindow('events/june.html#30','June','456','300','no','center');return true)" class=event>30</a>

    Note: remove the space between java and script (as this forum splits this word for unknown reasons )
    Reply With Quote
      #4  
    Old 07-01-2004, 02:36 PM
    ::bluemoth:: ::bluemoth:: is offline
    Registered User
     
    Join Date: Jul 2003
    Posts: 10
    Thanks for the replies.

    Quote:
    Originally posted by Kor
    <a href ="javascript:void(NewWindow('events/june.html#30','June','456','300','no','center');return true)" class=event>30</a>
    Should have mentioned that, the return false is necessary, as I want the link to also work for people without javascript. That is why I'm putting all the popup settings in an onClick event.

    I'm still having trouble doing this without the javascript though, so something is amiss with referencing.


    Quote:
    Originally posted by Mr J
    It is possible but you only mention the page loading into the popup window, what about the page loading into the Iframe?
    My understanding of iFrames is that you link to an anchor within it, by referencing the iFrame by id, and not the .html that the anchors reside within!?. If I've got that wrong, then I could really appreciate some help understanding how I need to reference the following path: window > iframe > html > anchor, as I have absolutely no idea.

    You also mention "It is possible" . . . have you ever seen this been done? I'd be very grateful for 'confirmation' on this, as I have never come across this.

    Any help, or other suggestions are very much welcomed.
    __________________
    ::bluemoth::

    Last edited by ::bluemoth::; 07-01-2004 at 02:46 PM.
    Reply With Quote
      #5  
    Old 07-01-2004, 03:10 PM
    Mr J Mr J is offline
    Registered User
     
    Join Date: Apr 2003
    Location: UK
    Posts: 2,203
    Are these anchors in june.html or the document in the iframe name list
    Reply With Quote
      #6  
    Old 07-01-2004, 03:15 PM
    ::bluemoth:: ::bluemoth:: is offline
    Registered User
     
    Join Date: Jul 2003
    Posts: 10
    Pardon my lack of accurate detail . . . the anchors reside within an iframe called list, which itself resides within june.html - the NewWindow I'm calling.
    __________________
    ::bluemoth::
    Reply With Quote
      #7  
    Old 07-01-2004, 04:15 PM
    Mr J Mr J is offline
    Registered User
     
    Join Date: Apr 2003
    Location: UK
    Posts: 2,203
    Take a look at the attached files to see if I am on the right track here

    Open pop_main.htm and then select one of the links
    Attached Files
    File Type: zip anchor_test.zip (1.2 KB, 573 views)
    Reply With Quote
      #8  
    Old 07-01-2004, 05:33 PM
    ::bluemoth:: ::bluemoth:: is offline
    Registered User
     
    Join Date: Jul 2003
    Posts: 10
    Thanks Mr J.

    Ineed that is exactly what I'm after. However, as you've illustrated, it needs help from javascript in order to actually work.

    But thank you very much for your help.
    __________________
    ::bluemoth::
    Reply With Quote
      #9  
    Old 01-02-2005, 02:26 AM
    dubmecrazy dubmecrazy is offline
    Registered User
     
    Join Date: Jan 2005
    Location: Los Angeles
    Posts: 4
    Mr J, or anyone who knows how to do a very similar thing.

    I have 2 iframes in one web page. I am trying to get the links from the left iframe to load a webpage into the right side iframe to a specific named anchor. It loads the webpage alright but it will not go to any anchors. However, if I refresh my browser, it then goes to the specified anchor.

    Left iframe code:

    Code:
    <iframe frameborder="0" 
    			  border="3" 
    			  width="200" 
    			  height="200" 
    			  src="sites.htm" 
    			  name="menu" 
    			  scrolling="auto" 
    			  MARGINWIDTH="5"
    			  MARGINHEIGHT="5"
    			  align="middle"; 
    			  background-color="transparent" 
    			  allowtransparency="true" 
    			  style="filter:chroma (color=CCCCCC)">
    			  </iframe>
    Right iframe code:

    Code:
    <iframe frameborder="1" 
    			  border="4" 
    			  width="200" 
    			  height="300" 
    			  src="thumbs.htm" 
    			  name="thumbframe" 
    			  id="tf1"
    			  scrolling="auto" 
    			  MARGINWIDTH="5"
    			  MARGINHEIGHT="5"
    			  align="middle"; 
    			  background-color="transparent" 
    			  allowtransparency="true" 
    			  style="filter:chroma (color=CCCCCC)">
    			  </iframe>
    Link to webpage and anchor to show up in right iframe:
    Code:
    <a href="thumbs.htm#gx" target="thumbframe">
    Named anchor in thumbs.htm page:
    Code:
    <a name="gx"></a>
    Heres a mess of code I was tooling around with to no avail. In case you can't tell, Im a javascript retard:
    window.location.hash="#sample";

    Code:
    parent.document.getElementById('tf1').document.location.href = 'thumbs.htm#avs'"; 
    <a href="javascript:parent.window.document.location.href = 'thumbs.htm#pop';" target="thumbframe">
    <a href="javascript:parent.location.href = 'thumbs.htm#avs';" target="thumbframe">
    <a href="javascript:parent.window.document.location.href = 'thumbs.htm#avs';>
    <a href="thumbs.htm#" onClick="javascript:parent.window.location.reload();" target="thumbframe">
    <a href="thumbs.htm#bossa" "javascript:parent.window.document.location.reload();" target="thumbframe">
    
    <A HREF="javascript: void 0" ONCLICK="window.frames.thumbbox.location.href = 'thumbs.htm#avs'">
    
    <a href="#" 
    onclick="parent.frames['thumbframe'].location.href = 
    'http://www.google.com/'; return false;">
    
    <a href="javascript:changeFramePage('thumbframe','thumbs.htm#avs')">Load  Yahoo</a> 
    <a href="#" onclick="parent.document.getElementById('tf1').document.location.href = 'thumbs.htm#avs"; return false;">
    
    <A HREF="javascript: void 0" ONMOUSEOVER="window.frames.thumbframe.location.href = 'thumbs.htm#bossa'">
    It seems like such a simple and practical task. I have been on every forum for more than a day and have yet to find a clue.

    Thank you in advance.
    Reply With Quote
      #10  
    Old 01-02-2005, 03:55 AM
    pj59 pj59 is offline
    Little Brother
     
    Join Date: Dec 2004
    Posts: 364
    Hello!

    Mozilla does not show the behaviour you are having that problem with. In IE you might use a javascript workaround to overcome it. Put this script into the head section of your sites.htm:
    PHP Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    var
    IE=(document.all);
    function
    scrollToAnchor(where){
    scrollY=parent.frames['thumbframe'].document.getElementById(where).offsetTop;
    parent.frames['thumbframe'].scrollTo(0,scrollY);
    }
    //-->
    </script>
    Your links could then look like this:

    <a href="thumbs.htm#gx" target="thumbframe" onmouseup="if(IE)scrollToAnchor(this.href.split('#')[1]);">goto gx</a>

    <a href="thumbs.htm#avs" target="thumbframe" onmouseup="if(IE)scrollToAnchor(this.href.split('#')[1]);">goto avs</a>

    etc....

    The only other thing to do is to assign ids to the anchors in your thumbs.htm which are the same like their names. Example:

    <a name="gx" id="gx"></a>

    This will do the job (provided that js is available in the user's browser). If you have links which open a different file in which you also want to use this function it may become necessary to delay the execution of the function to avoid that it runs before the new iframe document has been fully loaded.

    Regards PJ
    __________________
    &nbsp;
    Reply With Quote
      #11  
    Old 01-03-2005, 03:23 PM
    dubmecrazy dubmecrazy is offline
    Registered User
     
    Join Date: Jan 2005
    Location: Los Angeles
    Posts: 4
    Thumbs up

    PJ, you are a hero. Thank you so very much!
    Reply With Quote
      #12  
    Old 01-03-2005, 03:45 PM
    pj59 pj59 is offline
    Little Brother
     
    Join Date: Dec 2004
    Posts: 364
    Hi dubmecrazy!

    You are very welcome.

    PJ
    __________________
    &nbsp;
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:01 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.