473,804 Members | 4,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP pages don't respect my script..

manuelgk
54 New Member
Hello everybody, yesterday I had a problem with a script that I developed about 2 months ago.

The goal of this script is to detect the click events in the links contained in Web pages and, when this happens, the script should modify the URL of the links putting a string of our choice after the original URL.

The code of the script is shown next:

Expand|Select|Wrap|Line Numbers
  1. window.onload=function() {
  2.          if(window.frames.length>0){ 
  3.            for(x=0;x<window.frames.length;x++){
  4.    els=window.frames[x].document.body.getElementsByTagName('*');
  5.              for(c=0;c<els.length;c++){
  6.                els[c].onclick=function(){
  7.                  getOnclicks(this);
  8.                }
  9.              }
  10.            }
  11.          }
  12.          else{
  13.            els=document.body.getElementsByTagName('*');
  14.              for(c=0;c<els.length;c++){
  15.                els[c].onclick=function(){
  16.                  getOnclicks(this);
  17.                }
  18.              }
  19.            }
  20.          }
  21.  
  22. function getOnclicks(el) {
  23.          cadena=new String("?COLAB_CLICK=YES");
  24.          var ta=String(el.getAttribute('target'));
  25.          var url=String(el.getAttribute('href'));
  26.          if (el.tagName=="A"){
  27.              alert(el.href=el.href + cadena+ "\nDestino: " + ta);
  28.          }
  29.  }
The problem is that when I try the script in Web pages save locally in my computer it works well (both HTML and PHP pages). But when I try it on pages that are transmitted (and modified on the fly, adding the call to my script), it does not work anymore, what's wrong? should I forget to combine PHP with JS? do I have something wrong in my code? why does my script work in HTML pages and not in PHP ones?

Kind regards
Mar 5 '08 #1
10 1459
acoder
16,027 Recognized Expert Moderator MVP
But when I try it on pages that are transmitted (and modified on the fly, adding the call to my script), it does not work anymore, what's wrong?
Is it any different in PHP? How do you add it in the PHP page?
Mar 5 '08 #2
manuelgk
54 New Member
Well, I'm not exactly modify the PHP, I just put the script calling in the HTML page. So I think my script does not work because the page I have locally is the result of what PHP show us in Web: a HTML page, as you know PHP code is executed in the server side so is not possible to download the code of PHP pages. Thus if I'm right, the script never going to work because the main execution of the Web page is in the server and it shows us the page like a HTML, so if I modify this HTML with any JS, the script call is not going to take any effect in the page, right?
So what can I do? I hope you can give some advices I really appreciate it.
Kind regards
Mar 7 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Well, I'm not exactly modify the PHP, I just put the script calling in the HTML page. So I think my script does not work because the page I have locally is the result of what PHP show us in Web: a HTML page, as you know PHP code is executed in the server side so is not possible to download the code of PHP pages. Thus if I'm right, the script never going to work because the main execution of the Web page is in the server and it shows us the page like a HTML, so if I modify this HTML with any JS, the script call is not going to take any effect in the page, right?
You were right up to this point. The script, if included correctly, can have an effect on the page. Post the code or a link to a test page.
Mar 7 '08 #4
manuelgk
54 New Member
Well, another thing I forgot to tell you, maybe it could be possible the reson I write before about why my script does not work, but I think I can because the navigator show me the HTML and not the PHP. I read something about JS and PHP, and I found PHP can not be combine with JS, is that true?
the call script is like this:
Expand|Select|Wrap|Line Numbers
  1. <language script="text/javascript src=".../route"></script>
As I said, I put this in the HTML locally and it works, but in the Web it does not appear.
Thanks
Mar 10 '08 #5
rnd me
427 Recognized Expert Contributor
I read something about JS and PHP, and I found PHP can not be combine with JS, is that true?
no.
absolutely not.

php prepares a url for delivery to a browser.
php outputs html, css, and javascript as well.

it is all text to php, and no javascript is executed on a php server.

the browser can;t see the php and the php can't run the js.
Mar 10 '08 #6
acoder
16,027 Recognized Expert Moderator MVP
As I said, I put this in the HTML locally and it works, but in the Web it does not appear.
Try the HTML file on the web server. Does that work?
Mar 11 '08 #7
manuelgk
54 New Member
Before I start I'm really sorry if I answer today.
When I run the HTML in a server the js works but as you told me, PHP doesn't execut a js, now the question is, is there any way to detect the events in a php page (it doesn't matter if it isn't in JS)?
Kind regards
Apr 2 '08 #8
acoder
16,027 Recognized Expert Moderator MVP
now the question is, is there any way to detect the events in a php page (it doesn't matter if it isn't in JS)?
No, PHP is server-side while JavaScript is client-side. You need a client-side language to detect events.

Can you run any PHP script? Have you got a test link?
Apr 2 '08 #9
manuelgk
54 New Member
Well, I'm a little confuse about the PHP script, I think it is something similar to a js but in some pages I read they are PHP pages.
In the other hand, if my idea about PHP scripts is correct, what is the difference beteween make a JS and make a PHP script? does the PHP script is execute in the client side to?
Another think I read in your reply, something about "a client-side language", it means HTML for example, right?
About the links you ask me, the situation is the same, if I have it locally it works but in the internet not, I get the www.laas.fr, the PHP official site and my school page (www.itsx.edu.mx) and nothing happened.
Thanks for everything, please if you don't understad something about I write, please let me know it.
Kind regards
Apr 4 '08 #10

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

Similar topics

14
1876
by: Dafydd | last post by:
I have the following Script in my web page reduce to two pages. <script> function details() { document.getElementById('details').style.visibility='visible'; document.getElementById('capabilities').style.visibility='hidden'; } function capabilities() {
6
1257
by: Jamie | last post by:
Hi there, I have a bit of java script which I would like to include in all of my html pages. Is there an easy way to include it with a reference or something. I don't want to have to copy and paste the code to the top of each page as if I then change the code I have to go through all pages to change it.
10
2050
by: Jim | last post by:
Hi, Let me explain how I'd generally do things. For a page where the user edits data, I'd generally call it something like editfred.php (for example), the page which updates the data would be called updatefred.php and equally the page which processes a delete would be deletefred.php. I like splitting the pages up this way, it feels less cluttered and more organised than throwing all the functionality in one fred.php.
7
1968
by: Martijn Saly | last post by:
Hi there, I've created a master page with some controls on it, a Calendar control among others. Now depending on the date(s) selected, the content page needs to be updated. In the masterpage I've created StartDate and EndDate properties, which are basically wrappers around the SelectedDates property from the Calendar control. When I select another date in the Calendar, the page updates normally, but when Page_Load for the content page...
8
2259
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able to add comments at the bottom of each page, similar to the way the php, mysql, apache manuals work. PUNCHLINE_A:
17
3166
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
5
1366
by: Jens Jensen | last post by:
Hello, Does anyone know anything about how to optimise asp.net 2.0 pages for search engines? I'm thinking of a programmatic way of mapping sitemap structure to pages meta tags. Well it can always be done i'm just wondering of smart ways of doing it.
4
1308
by: Neil Gould | last post by:
Anthony Jones wrote: That it is awaiting user action. Since a While/Wend or some other on-going background activity of a script appears to provide exceptions to the above statement, your usage seems to be a distinction without a difference. Could you clarify? Yes. Could be. From my perspective, "members.asp" is in a sense a form (though
23
2413
by: Geoff Cox | last post by:
Hello, Is it possible to use php to generate different menus for users who have access to files in different folders? For example, user Fred might be able to access files in folders A, B and F, whilst use Jane might be able to access files in folders A, D and E. I would want each user to only see text and links relevant to the files in their chosen folders...
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7626
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.