Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. You don't echo it, you store it into a variable and do some processing on it.
  2. All it means is that Google will not follow the link, but unless the page itself has a noindex meta tag or is blocked by robots.txt Google can still index it. The nofollow link is usually used for links to external websites.
  3. You're missing a meta viewport tag in overview.html.
  4. You can do testing by typing the URL of the PHP script in your browser instead of using AJAX. This way you can easily see what's being printed to the screen. curl_exec() returns a boolean value, you should check to see if it's false, and if so then you can use curl_error() to see why it failed.
  5. Javascript searches for all elements on the page that have a certain value in their class attribute. Then it puts another element next to it. To open a file dialog, you just need a file type input, like this: <input type="file"> The Javascript library is putting one of those in the place of the original <i> element.
  6. It has nothing to do with the <i> tag itself. The Javascript library just looks for any elements with certain class names and replaces them with videos, links and other things. Any other element could have been used, but <i> was probably chosen because it's very short and has no semantic meaning. Everything you know about HTML, Javascript can break it. If you want to understand all of this better you will have to learn Javascript in depth.
  7. I would place my bets on most large websites using tabular databases because they are very efficient. I do believe that a lot of phone apps render HTML and CSS as well since it's a really convenient way to specify the layout of text and media. XML is not a good language, neither for transferring data nor storing it. It has too much redundant information and is slow to parse. For transferring data in a human-readable format, JSON is currently the best option.
  8. I'm not aware of a REMOTE_REFERER key in the $_SERVER array. Perhaps you meant to use HTTP_REFERER. But even then, an undefined key would not throw a 500 error. I can't tell you why it's doing that from just the code you provided, you should check the server's error log. If all you need is the referrer, though, Javascript already has that available without needing to send a request to the server. Use the document.referrer property.
  9. AJAX is not the correct tool for this problem. Why do you insist on using it? I already gave a solution that does not require reloading the page, use Javascript. It does not need AJAX.
  10. You can add query string parameters to the PHP file to decide which graph to show and use those query string parameters in the src attribute. PHP would use those parameters to decide which graph to show. One PHP file can show as many graphs as you want it to. It would be done like this: <img src="practice.php?graph=1"> <img src="practice.php?graph=2"> On the PHP end, you would show this: <?php header('Content-Type: image/png'); $graph_type = isset($_GET['graph']) ? $_GET['graph'] : 1; if($graph_type == 1) { $url ='https://.../matomo/index.php ?module=API &method=ImageGraph.get &idSite=1 &apiModule=Referrers &apiAction=getReferrerType &token_auth= ... &period=day &date=2018-04-10,2018-05-09'; } else if($graph_type == 2) { $url = 'Something else'; } else if($graph_type == 3) { $url = 'A third URL'; } else { $url = 'A fallback URL'; } $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_exec($curl_request); curl_close($curl_request); You can use more parameters in the query string if you want to more clearly identify the graph, I just use a graph number for simplicity. If you want the user to be able to change the image using dropdowns or sliders you can have Javascript generate the image URL, like this: <img id="image" src="practice.php?graph=1"> <select id="graph-type-dropdown"> <option value="1">Graph type 1</option> <option value="2">Graph type 2</option> </select> <script> var dropdown = document.getElementById("graph-type-dropdown"); dropdown.addEventListener("change", changeImage, false); function changeImage(e) { var type = e.currentTarget.value; var img = document.getElementById("image"); img.src = "practice.php?graph=" + type; } </script> There is no need for AJAX here. It would make the process much slower.
  11. You can't just assign a giant set of bytes to the src attribute of an image. What you actually should do is set the URL practice.php as the src of the image. On the PHP side, you should send a header indicating the type of image that is being displayed. I'm going to assume PNG, but you need to guarantee that you know the correct image type to make this work. PHP: <?php header('Content-Type: image/png'); $url ='https://.../matomo/index.php ?module=API &method=ImageGraph.get &idSite=1 &apiModule=Referrers &apiAction=getReferrerType &token_auth= ... &period=day &date=2018-04-10,2018-05-09'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_exec($curl_request); curl_close($curl_request); HTML: <img src="practice.php" alt="Line Chart of Referral Types"> Or you can even skip out on the PHP part and have the browser directly resolve the image for you: <img src="https://.../matomo/index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Referrers&apiAction=getReferrerType&token_auth= ...&period=day&date=2018-04-10,2018-05-09" alt"Line Chart of Referral Types">
  12. If you're working in a browser, the best approach is to add another <script> tag to your HTML document, everything declared globally in one Javascript file is accessible in all the other files that follow it. You seem to be working in Node.js. My experience with server-side Javascript is limited but there's a discussion about it here: https://stackoverflow.com/questions/4481058/load-and-execute-external-js-file-in-node-js-with-access-to-local-variables
  13. The difference between a regular Javascript variable and sessionStorage is that the global variable disappears as soon as the user leaves the page. sessionStorage remains as long as the user hasn't closed their browser, even if they leave your site and return to it in a few minutes.
  14. HTML doesn't do it. It's usually done on the server side by analyzing the User-Agent HTTP header. On the client side, Javascript has that information available in the navigator.userAgent property, but if you're working on the client side you also have access to the screen size and window size.
  15. You need to learn two things: Linear interpolation Timing in Javascript Linear interpolation is described here with some examples of function implementations: https://en.wikipedia.org/wiki/Linear_interpolation#Programming_language_support The time t in linear interpolation is a value from 0 to 1. To get this value, you just divide the amount of time that has passed since the animation started by the total duration of the animation. In pseudo-code, something like this: t = (currentTime - startTime) / (endTime - startTime) When the animation starts, you need to store the current time in a variable startTime to use it in the formula described above. In Javascript, when using setTimeout or setInterval, you get the startTime and currentTime values from the Date object's getTime() method. If you're using requestAnimationFrame, see Mozilla's documentation, the current time is given as a parameter in the callback function. When using requestAnimationFrame you can get the startTime value using performance.now() right before the animation begins.
  16. Have you built this function or are you asking how to build it? In Javascript, you would have to implement it by repeatedly calling a function using setTimeout, setInterval or requestAnimationFrame.
  17. I'm sorry, I'm just a volunteer forum moderator. I don't have any control over the website or even any direct communication with the website owners.
  18. To answer your question, Javascript can do pretty much anything. It can read the hash of the URL by accessing the location.hash property. It can construct a URL using string manipulation and then redirect the browser to another page using location.assign(). I recommend not doing any of that. On ordinary websites, it's not a good idea to use the hash for any other purpose other than what it was designed for. I don't know why you want to use the hash as a data transfer mechanism, but almost certainly there is a better way. You should clearly define your end goal before deciding which technologies to use to achieve it.
  19. Nothing that follows the hash ever gets sent to the server, not even if it looks like a query string. The hash is always the last part of the URL. In item 1), the server loads the index page. In item 2) the server loads the index page with access to the contents of the query string. Item 3) is identical to item 1), no additional information is sent to the server because all of the remaining data is in the hash, which is only used by the browser. HTTP is very commonly used in web services, so it's not out of place to ask about it on the Web Services forum, but most of your usage of HTTP pertains to HTML and PHP, so either of those forums would work as well.
  20. It does not improve SEO, in fact it's detrimental. I don't know where you heard that. You actually have it backwards, all hashes belong to the same page, Google treats different query strings as different pages. What does improve SEO is using a hash instead of nothing at all when using AJAX to change the page content. AJAX in itself is bad for SEO but some search engines offer the ability to use the hash to indicate that the page has changed, which reduces the harm of a Javascript-driven website. For Google, the hash must have a specific format, something similar to #/!/page-name, I'd have to look it up again to make sure I got that right. In conclusion, don't use the hash to identify your pages.
  21. It depends on your definition of "modal". The most common implementation of a modal window can't have a URL because it's just an element on the page that is manipulated with Javascript. It's possible to attach the modal behaviour to the hash part of a URL.
  22. The Javascript only targets the first h3 element on the page, it's pretty obvious from the code. I would hope you're not just copying and pasting code without knowing what it does.
  23. The file extension needs to be present for an image to show. As for viewing the source code, right-click on your web page and select "View Source" from the context menu. The source code that the browser sees is not the same as the source code that's on your server.
  24. I can't help you if you don't show me the code in a context where it doesn't work.
  25. I just tested the code in three browsers and it is working correctly, even in Internet Explorer. What is the issue?
×
×
  • Create New...