I used to have a traffic tracking script that used to work as follows:
Code:
<script type="text/javascript">
var tracking_image = new Image;
tracking_image.src = '/track.php' +
'?page=' + escape(document.location.href) +
'&referrer=' + escape(document.referrer);
</script>
This would interact with a PHP file which parsed this information and stored it in a database. However I just changed servers, and for some reason this JavaScript no longer works; don't know if it was because of the server move or what.
Is there any way to pass GET variables to an external javascript file? I would like to pass things like document.location.href and document.referrer to a PHP file. For instance something that would function like
Or alternatively, perhaps there is some other way for a PHP file to access JavaScript's document.location.href and document.referrer values (I'm using JavaScript to access this info rather than standalone PHP since spiders don't activate JS).
I have used AJAX lots before and I wondered if it was possible to set variables from an AJAX file E.g. an ajax file could set var set1 = 10; var set2 = 55; with both variables coming from an external file called by AJAX. Which JS side perform the request and the format of the file that is requested.
I need help getting variables in an external js file to transfer to the html page that uses them. I have an html page that lists verses to memorize, which, when the mouse hovers over a particular verse, a small popup reveals the book reference for that verse, thus giving a check to see if the user has accurately referenced that verse for its source.
I have an external js file (VERSES.js) that houses the verses and popup references sequentially as elements in an array and then writes them to the html document. A simplifed version of what I am using, with only a few verses listed here as an example, and that works beautifully, is given below: Code:
I am developing a script to work along side my joomla website and i am wanting to develop a script that connects to my database and refresh's certain divs every 2 seconds without the user noticing this,
only issue is that joomla isnt wanting to work with me on this,
since when i do that i get nothing on my navagation where user information is displayed and displays the enter layout in the div right_contenta So can jquery does this.
How can i fix this and get my right_contenta div refreshing every 2 seconds with my joomla layout
in otherwords i want my ajax to load and refresh the information located at profile2.php?user=admin which has all user information coming fom database and refreshs every 2 second
Code: <script type="text/javascript"> $(document).ready(function() { var window.amount=<xsl:value-of select="count(/data/fotos/entry)" />; var window.size= amount * 56;
[Code]....
Simple enought eh? However 'tracing' from code in the HEAD gives me correct values, but from the external .js gives me undefined. The reason I have to put my code away is because of XSL syntax limitations.
I'm writing a script and I've encountered a problem.. I have a txt file with many words, each word in a different line. For example: the file words.txt contains:
word1 word2 word3 word4 word5
I need to load the content of the file into a variable in my script. I prefer that all the words will be in the same variable with line breaks, but if you'll figure out a way to put it in an array, it's ok too. I really don't know how to do it, and I tried to google but didn't understand.. By the way, I don't want to change the txt file to js file, I need it to remain txt..
I got an [object error] from IE 7.0.5730.11 when moving the <script src="..." type="text/javascript" /tag from the <headpart to the <bodysection of a HTML file.
Is not possibile to include Javascript code via <script src="..." type="text/javascript" /from the <bodysection, instead from the <headone? If yes, anyone has any idea of which the problem could be? If not, how can I programmatically include a javascript external file inside the <bodypart of a HTML file, for example, using Javascript to some particular native functions?
I have a external file for example abc.js ,in this abc.js file no functions ,it contains some scripting,i want to call the scripting file though html I use the code
For some reason, I am using document.referrer in a PHP script that is called as a JavaScript script. The problem is that I need to pass the value of document.referrer to a PHP variable (in the same file) in order to add it to the database. How can I do that?
I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so:
<script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js }
in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load.
However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem.
My options are:
1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense.
2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers).
jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work.
I'm writing a script and I've encountered a problem.. I have a txt file with many words, each word in a different line. For example: the file words.txt contains:
word1 word2 word3 word4 word5
I need to load the content of the file into a variable in my script. I prefer that all the words will be in the same variable with line breaks, but if you'll figure out a way to put it in an array, it's ok too. I really don't know how to do it, and I tried to google but didn't understand.. By the way, I don't want to change the txt file to js file, I need it to remain txt..
This probably seems pretty trivial to you experts but I just don't know why it doesn't work and would like a nudge in the right direction please.I have a sllide and fade that works great - no problems. I am firing it with a function call from the HTML like so;<a href='#' onClick='sfade('#s1'); return false;>as you see I am passing the div to be faded(and slid) as a variable. Works great. The receiving function is:
var str=''; function sfade(str){ $(str).slideFadeToggle(1000);
I'm creating dynamic buttons and forms for a website and would like the form hidden when it's corresponding button is clicked. However, when I pass button and form name variables to my JavaScript that hides the form, the variables are not being recognised unless I explicitly set them. (e.g 1 and 2 as seen below).
In a nutshell the onlick event doesn't seem to like PHP variables !
Don't know if this should be under JS or PHP... I have 2 different pages. On the first one, a table shows a list of items. Each has a button that when clicked opens another window with specific size attributes, hence the onClick event. The 2 PHP variables are computed and different for each item (each line).
Now of course, on the popup window, the URL will show .../player_buy.php?send_role=XXX&send_price=XXX
But the goal is to avoid that. So my question is: Is there a way to open such a popup window, pass these variables to it but in a way that it would not show in the URL?
I have a javascript function that receives the form name, field name and value and I want to be able to spit that data back to the originating form after doing some processing on the data.
The values are making it to the function perfectly, but when I try to return those values to the form, it tells me it's not a function. I know there's some syntax problem, but I'm just not sure where!
function doThis(one,two,three){ var myFormName = one; var myFormField = two; var myFormValue = three; var goHere = myFormName + '.' + myFormField;
I want to pass 2 variables from a html page and collecting in another html page using javascript. Say I pass xyz and abc to a page 2.html from 1.html without using cookies. In 1.html page i have many links. each link should be able to pass different variable to 2.html. When some one clicks on a link the variables should be passed to 2.html. I want to know how to collect them and use them.
I have one page witih PHP where users will be answering a form for file upload. However, I need to give them the option to either upload a file or select one that is already uploaded.
In order for them to select a file that is already uploaded, they will use a pop up window to browse to the file and and select the a file with a radio button or submit button to select the file.
What i need to happen is when they press "select" they window needs to close and that file's url or relative path needs to fill in the "select uploaded file" with the path or url.
I"ll be using PHP in both form and popup for the file, but I cant do that with php without refreshing the page. Can javascript do this and how would I go about this.
A while back I was working on learning C++. However after finding out that making API's was too difficult I switched over to HTML and Javascript for a while to get it to do what I want without having to fry my brain on weird code statements.
Well now I've reached the barrier of being able to save data. For a while I've just had it to the point where the code I need is saved in a textarea and I copy and paste it in notepad. Then upon reentering I pull it out of Notepad and paste into the testarea.
Well enough with the bla bla bla. Is there a way I can use the <form method="post"> stuff to pass a variable to a C++ compiled program?
All I need to know is: 1) can I use <form method="post" action="SomeProg.exe"> and 2) what would the name of the posted variable be to use in my C++ code? As you can tell I running client-side so PHP and other server-side languages that WinXP don't support without special installation wont work.
How to pass (well more like bridge) session information to the client side from server side.
Right now, what I'm basically doing is echoing the userID and the username into a method in JavaScript tag at the bottom of every page.
The reason why I am doing this is simply for AJAX-related interactivity.
This is an example of what the code looks like:
Code:
A) It requires JavaScript code to be pasted within the HTML document (its non-external).
B) It requires the code to be echoed in EVERY PAGE.
C) A PHP Script or Class must maintain the responsibility of printing the session values.
D) The variable data cannot be accessed from any imported javascript files prior to where it was printed.
Now, I'm wondering about using Cookies. This would benefit me since I don't have to inject any ugly javascript code into the HTML output. I can also remove the PHP script that echoes the values and the changes will be purely handled in PHP (cookies can be updated!).
The only issue that's stopping me is simply security. Since cookies can be edited very easily on the client side, then the data can be changed. But then again so can the JavaScript (using a tool like Grease Monkey).
Once again, I am aware to never ever to trust the client side data without any validation; therefore using some sort of hash checksum, the cookie data can be compared to its PHP equivalents.
I've been workling seperately with PHP/ MySQL and am now trying to get things together with jQuery which I have so far only used with non-dynamic content. Here is the setting I am trying to achieve:
I have one php file that generates two different contents depending on the setting of a status-variable $ncs. If $nsc=0 the main page is loaded, showing an overview of all available news-articles. If $ncs=1 the content of a specific article is shown fully. The jQuery connected to each case differs. So i would like to pass the varible $ncs over to my jQuery script:
Code JavaScript:
I have checked that $ncs is not NULL on the rendered page. However after being passed to the jQuery script the variable is undefined. I have never connected PHP and jQuery so it is probably a general twist in my idea of how it works. I tried passing different variables and all are undefined in jQuery. What do I have to attend to when passing PHP-variables to jQuery?
I am attempting to display info put into an array from an onClick() event in a different page - I have created different functions which populate an array with different info dependant on which link the visitor clicks ie HTML Code:
The function seems to work fine, however when the next page loads and I attempt to access the array elements they are now undefined - both pages are linked to the same JS document.
Basically, I have a window with an empty text field in. When I click on a link, another window appears on top of the first. (A pop up window.)
The popup window also has a text field in it. If I type "Test" in the popup window's text field and click "Submit", is there a way I can send that value to the empty text field in the first window?
We have a content management system that requires us to fill in 20 fields for metadata about a page. We store the metadata in a separate database for our records.
I'd like to be able to open a window with the data from our database, click a link, and have it fill in the form in the content management system (hosted by a different organization, so window.opener is out of the equation).
I tried this
<a href="#" onClick="window.open('http://www.google.com', 'Google'); window.Google.f.q.text.value='my name'">Enter my name in Google!</a>
In this example, I'd click a link that would open up Google, then pass the value "my name" to Google's search bar. Unfortunately for me, it didn't work.
Am I asking too much? I'd hate to have to rekey or copy/paste 20 fields worth of metadata each time I create a page.