Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: opening a new page and running a script on it, from the old page.

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question opening a new page and running a script on it, from the old page.

    Hey guys, I'm building a website and using a small javascrpit, such that I have one html file containing the entire site. page1.
    At the moment, the script is used to edit various div's making them either visible or not, as the user navigates.
    I'm quite happy with that function, but ... with growth, I need something more.

    The code is visible at the bottom of the post.

    Currently I call the code such that obj='this', allowing the script to run through the html on the users computer and edit the site in front of them.
    This has worked well while my site has been small, but it's growing such that in some instances I need to open a new page. page2.
    Simple enough, but is there a way to open page2, AND instruct the code to edit page2, all still from page1?

    Logic tells me that the trick involves replacing 'this' when I call the code in page1 with ... the url of page2.
    Or that adding an href for page2, and then also replacing 'this' with 'new' (or something else), would run the code on the new page...

    I'm still playing with google to find the answer, but I've been coming up dry.
    I'm not a professional programmer, but did pass the coding exams back in school (we used object pascal).
    Even this code I am using is frankencode, stitched together from something I found in a code bank.

    Any help would be greatly appreciated.

    This is the html call.
    <a onclick="return showTab(this, 6, 3, 13, 0, 0);">

    function showTab(obj, ctabid, tab, framepid, fs, sp)
    {
    par = obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
    divs = par.getElementsByTagName("div");
    for (i=0;i<divs.length;i++)
    {
    c = divs[i];
    if (c.className.match(/ctab/gi))
    {
    if (c.className == "ctab"+ctabid) c.style.display = "";
    else c.style.display = "none";
    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: opening a new page and running a script on it, from the old page.

    Thread moved.

    JavaScript != Java.

Similar Threads

  1. How to give refrence of java script file and css file in jasp page????
    By ambblr108 in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: August 14th, 2014, 02:35 AM
  2. How to give refrence of java script file and css file in jasp page????
    By ambblr108 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 14th, 2014, 01:18 AM
  3. Replies: 6
    Last Post: August 4th, 2014, 05:04 AM
  4. Notepad is opening on click of submit instead navigating to other page
    By pb60705 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 10th, 2011, 07:23 AM
  5. Downloading web page with java script enabled through Java
    By mashimaro in forum Java Networking
    Replies: 1
    Last Post: November 13th, 2010, 09:28 PM