This is a discussion on "php and javascript" within the JavaScript Forum section. This forum, and the thread "php and javascript are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
php and javascript
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
php and javascript
hi please help, i am trying to embed javascript with php but it doesn't work. Want i want to happen is to check on the javascript script first if javascript is not available then php header function should be called can somebody correct this code
<script language="JavaScript" type="text/javascript"> if(window.opener){ opener.location.reload(true); self.close(); } else{ <?php header('location:index.php');?> } </script>'; |
|
|
|
#2
|
||||
|
||||
|
Re: php and javascript
You cannot put PHP inside JavaScript, only the other way around. JavaScript is client side, so the PHP will never get parsed.
|
|
#3
|
|||
|
|||
|
Re: php and javascript
Thanks for that info ryan
|
|
#4
|
||||
|
||||
|
Re: php and javascript
Use window.location() to redirect the browser.
|
|
#5
|
|||
|
|||
|
Re: php and javascript
Thanks again ryan
|
|
#6
|
|||
|
|||
|
Re: php and javascript
Hi ryan, i tried using window.location but it didn't work here's how i did it
<script language="javascript" type="text/javascript"> if(window.opener){ opener.location.reload=true; self.close; } else{ window.location="index.php"; } </script> |
|
#7
|
|||
|
|||
|
Re: php and javascript
Why use javascript at all then? If you're going to use PHP anyways, leave out the javascript, and no one will know the difference.
try using window.close instead of self.close |
|
#8
|
||||
|
||||
|
Re: php and javascript
JavaScript is an awesome language. Used with PHP, the combination is almost unstoppable.
|
|
#9
|
|||
|
|||
|
Re: php and javascript
yup, very well said, of course i am also making sure that if javascript is disabled or unavailable people can still surf my site thats my i am looking for ways to incorporate javascript with php
|
![]() |
| Tags |
| validation |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Javascript Help | Daniel | JavaScript Forum | 5 | Jan 4th, 2007 22:00 |
| JavaScript | cbrams9 | JavaScript Forum | 1 | Sep 20th, 2006 17:35 |
| using xml in javascript | shailu | JavaScript Forum | 0 | Jul 25th, 2006 07:36 |
| Can someone help me with this javascript | Galaxyblue | JavaScript Forum | 2 | Mar 11th, 2004 12:18 |
| what does \\ mean in javascript | jenjen1018 | JavaScript Forum | 5 | Jan 6th, 2004 17:05 |