SitePoint Sponsor

User Tag List

Results 1 to 20 of 20

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have 2 questions. One is a perl question and the other is a Javascript question.

    First the Perl question:
    I need a script that will find something in an HTML document and replace it with something else. For example:
    The script will replace "Receive" with "Recieve".

    and the Javascript question:
    I need a Javascript that will detect if a window is open. If it is opened, it just brings it up. If it isn't open, then it opens it.
    For example: If someone clicks the "Help" link, and then they minimize it, and click the link again, then it will just bring up the already-opened window, and will not pop up a new window.


    Thanks!
    Bryan
    AIM: Link241
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  2. #2
    I believe you have my stapler. scrubz's Avatar
    Join Date
    Feb 2001
    Location
    Van down by the river
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To open a new window, you can use a function like this:

    <script language="JavaScript">
    <!--
    function openWindow() {
    popupWin = window.open('http://www.google.com/', 'myWindow', 'scrollbars,resizable,width=640,height=480')
    }
    -->
    </script>

    Call the script by adding an onClick to a form button or a link:

    <a href="#" onClick="openWindow();return false;">Google</a>

    Then in your child window (the popup window), use this:

    <script language="JavaScript">
    <!--
    window.focus();
    -->
    </script>

    No need to check to see if the window is open, since you gave it the name 'myWindow' in the function. If it's not open, it opens, if it's already open, it brings the window to the front.

  3. #3
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you so much.

    And the perl question?
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  4. #4
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, for the javascript, how would I do it if there was bookmarks in the child window?

    Thanks
    Bryan
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  5. #5
    I believe you have my stapler. scrubz's Avatar
    Join Date
    Feb 2001
    Location
    Van down by the river
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure exactly what you mean, so let me read your mind for a moment...

    Are you wanting to click links in the popup and have them open in the parent window? If so, there are a few ways to do it. Here's one...

    <a href="http://www.google.com" onClick="window.opener.location.href = 'http://www.google.com';return false;">Google</a>

  6. #6
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No...

    I mean, on the parent page, there would be links to different bookmarks on the child page (like #bottom #top etc.). I tried this and when you click the link, it goes there on the child page, but the child page doesn't pop up.

    Thanks
    Bryan
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  7. #7
    I believe you have my stapler. scrubz's Avatar
    Join Date
    Feb 2001
    Location
    Van down by the river
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure that this JavaScript is in the child window:

    <script language="JavaScript">
    <!--
    window.focus();
    -->
    </script>

    Then, as long as you're correctly calling the child from the parent, the child window will pop to the front when it's called.

  8. #8
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I have that, but it doesn't pop up. It goes to the bookmark on the page, but the child window doesn't pop up... any ideas?
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  9. #9
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I'll show you waht I have, and you can fix it:
    This is the parent window:

    <html>
    <head>
    <title>CHA</title>
    <script language="JavaScript">
    <!--
    function openHelp() {
    popupWin = window.open('chatest2.html#Helpdown', 'help', 'width=300,height=400,top=0,left=0,menubar=0,location=0,scrollbars=1,directories=0,status=0,toolbars=0,resizable=0')
    }
    -->
    </script>
    <script language="javascript">
    <!--
    function openHelp2(){
    popupWin = window.open('chatest2.html#Helpfurtherdown', 'help', 'width=300,height=400,top=0,left=0,menubar=0,location=0,scrollbars=1,directories=0,status=0,toolbars=0,resizable=0')
    }
    -->
    </script>
    </head>
    <body>
    <a href="" onClick="openHelp();return false;">Help, down the page</a>
    <a href="" onClick="openHelp2();return false;">Help, further down the page</a>
    </body>
    </html>


    This is the child window:

    <html>
    <head>
    <title>CHA</title>
    <script language="JavaScript">
    <!--
    window.focus();
    -->
    </script>

    </head>
    <body>
    Help page.<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><a name="#Helpdown">Help, but down the page.</a><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><a name="#HelpfurtherDown">Help, but even further down the page.</a><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    </body>
    </html>


    K, what happens it discribed in my post above... please help!

    Thanks
    Bryan
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  10. #10
    I believe you have my stapler. scrubz's Avatar
    Join Date
    Feb 2001
    Location
    Van down by the river
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I see. It must be something with the anchors, because the window.focus() in the child window usually works.

    Plan B: You can remove the window.focus() from the child window, and just add this line to your openHelp function after opening the window...

    popupWin.focus();

    By the way, if you're going to be linking to that window a lot, you could use one function to do it, and pass the name of the anchor you want to use to the function...

    <script language="JavaScript">
    <!--
    function openHelp(whichAnchor) {
    popupWin = window.open('chatest2.html#' + whichAnchor, 'help', 'width=300,height=400,top=0,left=0,menubar=0,location=0,scrollbars=1,directories=0,status=0,toolbars=0,resizable=0')
    popWin.focus();
    }
    -->
    </script>

    And then pass the anchor name in your call to the function...

    <a href="" onClick="openHelp('Helpdown');return false;">Help, down the page</a>
    <a href="" onClick="openHelp('Helpfurtherdown');return false;">Help, further down the page</a>

    That should do it!

  11. #11
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow, thank you so much.

    Bryan
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  12. #12
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, that worked perfectly in Internet Explorer but not in Netscape... I run NS 4.6, it should work... any ideas?
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  13. #13
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What happens in Netscape is, it opens up the window, but just goes straight to the bottom. Then if you minimize it and click another link, it brings up the window, but it's still at the bottom. I think Netscape's not recognizing the bookmarks. I have them like this: <a name="#bm">Word</a>, it might not work in netscape. Any ideas?
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  14. #14
    I believe you have my stapler. scrubz's Avatar
    Join Date
    Feb 2001
    Location
    Van down by the river
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't tested it, but I seem to remember Netscape having a problem with using the # symbol in the name of the anchor. Try naming your anchor 'bm', without the #. But in your links of course, you'd refer to the anchor as #bm...

    <a href="myPage.html#bm">To anchor</a>

  15. #15
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much! It worked!
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  16. #16
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, can anyone help with the Perl question?
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  17. #17
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assume you know a bit about Perl

    Code:
    $text = "Blah, blah, receive receive and receive";
    $text =~ s/receive/recieve/g;
    print $text;
    # output: Blah, blah, recieve recieve and recieve
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  18. #18
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, that's all I needed, thanks!
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  19. #19
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me test it out and see if it works
    Last edited by Link241; Mar 27, 2001 at 20:29.
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]

  20. #20
    SitePoint Member
    Join Date
    Mar 2001
    Location
    California (I hate it here)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm.... can you write me up an example? I can't seem to get it to work... I want to change
    <b>Link241</b> to <big>Link241</big>

    thanks
    http://beyondgaming.cjb.net [The best damn boards you'll find. Beyond Gaming.]


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •