473,466 Members | 4,869 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I redirect from one html/js document to another within a function?

Blue1244
39 New Member
How do I redirect from one html/js document to another within a function? I am trying to reduce the amount of code within one function so I don't get confused. Need help. If you need my code ask and I will post.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>
  5. Math Game
  6. </title>
  7. <style>
  8. </style>
  9. </head>
  10. <body>
  11. <script type="text/JavaScript">
  12. function start()
  13. {
  14. var a= confirm("Are you sure you want to continue to the game?");
  15. if (a==true)
  16. {
  17. //Here is where it should take the viewer to the other html document.
  18. }
  19. else
  20. {
  21. window.close();
  22. }
  23. }
  24. </script>
  25. <center><button onClick="start()">Start</button></center>
  26. </body>
  27. </html>
  28.  
Aug 22 '13 #1

✓ answered by shadowstrike

Hi
I went through yout code and I thought the easiest way to acheiv what you want is by this method:-
Expand|Select|Wrap|Line Numbers
  1. <button onClick="window.location.href='html_page_where_you_want_to_navigate.html'" />
  2.  
Lemme know id that works

7 1632
Dormilich
8,658 Recognized Expert Moderator Expert
If you need my code ask and I will post.
yepp, we will need to see your code.
Aug 23 '13 #2
Blue1244
39 New Member
Ok I will edit the post.
I still have some work to do on it before I can post it.
Aug 23 '13 #3
Blue1244
39 New Member
oh and, Dormilich, I need to know how to run a function form within another function again, the post got deleted because it was too short.
Aug 23 '13 #4
Dormilich
8,658 Recognized Expert Moderator Expert
I need to know how to run a function form within another function
weird question ... look at lines #14 and #21. there you do exactly that.
Aug 24 '13 #5
shadowstrike
21 New Member
Hi
I went through yout code and I thought the easiest way to acheiv what you want is by this method:-
Expand|Select|Wrap|Line Numbers
  1. <button onClick="window.location.href='html_page_where_you_want_to_navigate.html'" />
  2.  
Lemme know id that works
Aug 24 '13 #6
Blue1244
39 New Member
Yes it worked! Thank you. I added the
Expand|Select|Wrap|Line Numbers
  1. start();
before the
Expand|Select|Wrap|Line Numbers
  1. window.location.href='nextpage.html'
and it worked :D.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>
  5. Home Page
  6. </title>
  7. <style>
  8. </style>
  9. </head>
  10. <body>
  11. <script type="text/JavaScript">
  12. function start()
  13. {
  14. var a= confirm("Are you sure you want to continue to the game?");
  15. if (a==true)
  16. {
  17. //Here is where it should take the viewer to the other html document.
  18. }
  19. else
  20. {
  21. window.close();
  22. }
  23. }
  24. </script>
  25. <center><button onClick="start(); window.location.href='page_1.html'" />
  26.  Start</button></center>
  27. </body>
  28. </html>
  29.  
  30.  
Aug 24 '13 #7
shadowstrike
21 New Member
your welcome..... :D......
Aug 24 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Robert Oschler | last post by:
Is there a module/function to remove all the HTML entities from an HTML document (e.g. - &nbsp, &amp, &apos, etc.)? If not I'll just write one myself but I figured I'd save myself some time. ...
2
by: gregl | last post by:
Anyone know how to obtain the true size of the html document's body? The control contains the size that the control was set to. The body object appears to contain the same size. That information...
1
by: carussell23 | last post by:
Is it possible to execute a batch file on the webserver and redirect to an html document at the same time using javascript?
1
by: mike | last post by:
regards: A HTML document can be converted to XHTML document. one step is:'Un-minimize' minimized attributes What does the step mean in easy english?...@@. I mean what operations I should do...
2
by: Filippo Bettinaglio | last post by:
Hi, I use, VS2005 C# I have a Windows Forms UserControl hosted within Internet Explorer According to MIcrosoft documentation: ...
7
by: Peter | last post by:
Hi there, I am using this code to retrieve the current URL: function selfURL() { $s = empty($_SERVER) ? '' : ($_SERVER == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER), "/").$s;...
4
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my...
3
by: SMH | last post by:
Normally an SVG document is loaded/parsed/interpreted inside an HTML document using an 'object' (or 'embed') element, although there are supposedly other ways too. The problem is, the SVG document...
3
by: akb | last post by:
hi i have two html aa.html and bb.html. there is a combo box in aa.html. i have to pass the selected combo box value to bb.html. and recieve that value in bb.html. what i have already tried...
11
Dormilich
by: Dormilich | last post by:
Lately I have seen so much awful HTML, that I like to show what a HTML document should look like, regarding the requirements from the W3C. the absolute minimum is defined as: or expressed in...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.