#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Whitehorse, Yukon Canada
    Posts
    41
    Rep Power
    14

    Wink Javascripting anger!


    Trying to make a simple javascript that when a link or image in html is selected it redirects the user to the appropriate help file. I'm a total javascript newbie..any help is greatly appreciated.

    Cheers,

    milady
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    la, ca
    Posts
    84
    Rep Power
    14
    Hi,

    I'm not really sure what you mean... why does it need to be done with JavaScript? Can't you just use standard anchor HTML tags like <a href="whatever.html">click here</a>?

    Regardless, the basic way to relocate the user with Javascript is with:

    document.location.href = "wherever.html";

    or

    window.location = "wherever.html";

    So, a shot in the dark for a function that would do what you're describing would be something like:

    <script language="javascript" type="text/javascript">
    function redirectMe(location){
    document.location.href = location + ".html";
    }
    </script>

    Then, you'd put in your HTML something like:
    <a href="#" onClick="redirectMe('wherever.html');"><img src="whatever.gif"></a>

    But, it makes more sense to cut out the javascript and do:
    <a href="wherever.html"><img src="whatever.gif"></a>

    So, if this doesn't help, more specifics would probably be needed.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Whitehorse, Yukon Canada
    Posts
    41
    Rep Power
    14

    Wink javascripting anger!


    ok.. what i'm trying to do is this;

    when a user clicks on the ? to get help on a certain subject((Onmouseover=help) i'm not sure if i want to use an image or text yet..) i would like the corresponding help file to open in a popup box. Does this make things any clearer for you?
    Thanks for your reply btw

    Cheers,

    milady
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    la, ca
    Posts
    84
    Rep Power
    14
    OK, here's how I'd do it.

    [in the head section]
    <script language="JavaScript" type="text/JavaScript">
    function popUpWin(page){
    window.open(page, 'helpwin', 'height=400px, width=500px, scrollbars=yes, resizable=no');
    }
    </script>

    [in the body section]
    <a href="javascript: popUpWin('thishelp.html');">?</a><br>
    <a href="javascript: popUpWin('thathelp.html');">?</a>

    (there shouldn't be a space between javascript: and popUpWin. I had to do it because it gets converted into a smiley AND, there shouldn't be a space between 'java' and 'script')

    When the user clicks on the "?", a popup window is created. The popup's named 'helpwin', it's dimensions are 500x400, it has scrollbars, and it's not resizable. You can change any of these attributes by messing around with the arguments of the window.open method.

    So, the page that fills the pop up window is the argument you pass to the function. The top "?" brings up thishelp.html and the bottom "?" brings up thathelp.html.

    You *will* have to type in the specific help page that will come up when the user clicks the "?". There's no easy way to make the corresponding help file automatically become the argument that's passed to the function. There are situations when this can be done, (for instance, if you're using a server-side language to do it and you have a bunch of pages you want to have help files linked to, you can create a loop and automatically pass the arguments), but I don't know if it's practical for your situation. Plus, it's a bit more complicated. I sense that's what you were driving at doing.

    Good luck!
    Last edited by dsknkt; May 23rd, 2001 at 05:22 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Whitehorse, Yukon Canada
    Posts
    41
    Rep Power
    14
    cool! i'll give that a try and see if it works

    Tanks dude

    Cheers,

    milady
    milady
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Whitehorse, Yukon Canada
    Posts
    41
    Rep Power
    14
    works excellent my only gripe is that when i click onthe ? in netscape it opens a full sized window.. does this have to do with the size being defined as height=400px, width=500px ?
    is there some way to get around this?

    Thanks
    milady
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    la, ca
    Posts
    84
    Rep Power
    14
    Oops! Try taking out the spaces between height=400px, width=500px, scrollbars=yes and resizable=no. That should do it.

    Glad I could be of help

    <script language="JavaScript" type="text/JavaScript">
    function popUpWin(page){
    window.open(page, 'helpwin', 'height=400px,width=500px,scrollbars=yes,resizable=no');
    }
    </script>
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Whitehorse, Yukon Canada
    Posts
    41
    Rep Power
    14
    ok.. i'm so blonde today.. heh
    any idea why this won't work? using html, php and javascript

    printf ("<HTML>");
    printf ("<HEAD>");

    printf ("<TITLE>E-Rims ~ Add Category</TITLE>");
    printf ("<META name=\"description\" content=\"\">");
    printf ("<META name=\"keywords\" content=\"\">");
    printf ("<META name=\"generator\" content=\"CuteHTML\">");
    printf ("<META http-equiv=Pragma content=no-cache>");





    printf ("<script language=\"JavaScript\" type=\"text/JavaScript\"><!-- ");

    printf ("function popUpWin(page){");
    printf ("window.open(page, \'helpwin\', \'height=400px,width=500px,scrollbars=yes,resizable=no\');");
    printf ("}");
    printf ("//--></script>");






    printf ("</HEAD>");
    printf ("<BODY BGCOLOR=\"white\" TEXT=\"navy\" LINK=\"white\" VLINK=\"#800080\">");
    printf ("<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" height=\"100%%\" width=\"60%%\" align=\"center\">");
    printf ("<form name=\"categories\" method=\"post\" action=\"categories.php3?function=10\" enctype=\"text\">");
    printf ("<tr>");
    printf ("<td align=\"left\" valign=\"top\" height=\"140\" width=\"99%%\" colspan=\"2\"><img src=\"images/logo7.gif\"><br><img src=\"images/categories.gif\"><br><hr><font face=\"arial\" size=\"3\" color=\"navy\"><B>%s</B>",$user_ref[1]);
    if ($num_cats[0] == 0) {
    printf ("<BR>There are currently NO categories for this race</font></td>");
    }
    if ($num_cats[0] == 1) {
    printf ("<BR>There is currently 1 category for this race</font></td>");
    }
    if ($num_cats[0] >= 2) {
    printf ("<BR>There are currently %s categories for this race</font></td>",$num_cats[0]);
    }
    printf ("</tr>");
    printf ("<tr>");
    printf ("<td align=\"left\" height=\"40\"><font face=\"arial\" size=\"4\">*Category Name</font></td>");
    printf ("<td align=\"left\" height=\"40\"><input type=\"text\" name=catname size=30 maxlength=\"30\"></td>");
    printf ("</tr>");
    printf ("<tr>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><font face=\"arial\" size=\"4\">&#160;Category Start &#160;Time&#160;(HH:MM:SS)</font></td>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><input type=\"text\" name=\"catstarttime\" size=8 maxlength=\"8\"></td>");
    printf ("</tr>");
    printf ("<tr>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><font face=\"arial\" size=\"4\">&#160;Category Weighting</font></td>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><input type=\"text\" name=\"catweight\" size=3 maxlength=\"3\"></td>");
    printf ("</tr>");
    printf ("<tr>");
    printf ("<td align=\"left\" height=\"40\" wdth=\"50%%\"><font face=\"arial\" size=\"4\">&#160;Category Race Legs</font></td>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><input type=\"text\" name=\"catraceleg\" size=3 maxlength=\"3\"></td>");
    printf ("</tr>");
    printf ("<tr>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><font face=\"arial\" size=\"4\">&#160;Category Group Index</font></td>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><input type=\"text\" name=\"catgroupindex\" size=3 maxlength=\"3\"></td>");
    printf ("</tr>");
    printf ("<tr>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\"><font face=\"arial\" size=\"4\">&#160;Category Gender</font></td>");
    printf ("<td align=\"left\" height=\"40\" width=\"50%%\">");
    printf ("<SELECT NAME=catgender>");

    printf ("<OPTION VALUE=0>Mixed");
    printf ("<OPTION VALUE=1>Male only");
    printf ("<OPTION VALUE=2>Female only");

    printf ("</SELECT>");
    printf ("</tr>");





    <------------ damn smilies!! hehe ---------------->

    printf ("<a href=\"javascriptopUpWin('thishelp.html');">?</a><br>
    <a href=\"javascriptopUpWin('thathelp.html');">?</a>




    printf ("<tr>");
    printf ("<td align=\"center\" valign=\"bottom\" colspan=\"2\" height=\"80\"><INPUT TYPE=\"submit\" value=\"Submit\"></td>");
    printf ("</tr>");
    printf ("<tr>");
    printf ("<td align=\"center\" width=\"100%%\" colspan=\"2\">* Required Fields</td>");
    printf ("</tr>");
    printf ("</form>");
    printf ("</table>");
    printf ("</BODY>");
    printf ("</HTML>");
    milady

IMN logo majestic logo threadwatch logo seochat tools logo