I have a website (hellostory.org) with a custom event that's fire when a user clicks a link. Instead of re-loading the entire page a fetch request is issued, the server processes the <main> tag content, and then the <main> content is entirely replaced with the server's response.
The reason for this is three-fold:
refreshing the entire page content is not optimal for this kind of content
my own benchmarking has found that fully refreshing the page is an order of magnitude slower than just processing the rendering that changes from page to page
a better user experience, especially on mobile.
Problem is though, the ads never refresh. I'm wondering if any of you guys have had a similar problem? How have others tackled Adsense for single page applications? Any advice that won't violate Google's TOS? Or maybe even documentation from Google on this topic?
EDIT: To clarify, I only want to refresh the page when my custom "user clicked a link" JS event fires.
This is being done with:
googletag.pubads().refresh();
It is against the TOS of Adsense, but you can use it with Adsense + DFP (Double click for publishers)
This documentation should point you in the right direction
Remember to use DFP, or you will get banned!
Related
I have a HTML page which I want to display on browser. This is a login page(https://localhost:9000/login). Before loading this over browser page I want to hit another url which gives me another html page . This url is basically to kill the existing sessions.(https:xyz)But this also redirects me to another page which I don't want to display . I want to remain on login page.
I think this is possible using iframes. I am newbie to iframes. Any pointers on how to achieve this?
That's a local link only viewable on your computer.
So you want to load another page, before the login page? If you want to kill existing sessions you can use sessionStorage for that.
There are a few things that don't make sense with this, but it's your project. like you want to redirect to another page, but don't want that page to display. That makes no sense to me.
You want to remain on login page, but when you login, you want to get another html page in the login page?
iframes are probably the worst thing in the world imo... you got so much going on here, but can simplify this so much. A login page to an inner page and then you go from there.
There are a number of ways to achieve the end means here, sessionStorage being one. Just search around here for answers, you can find a ton of them.
Good luck!
iframes have been removed from HTML specifications, you cannot use them in HTML5.
Use attribute target="_blank" in the <a> of this url. It will open in a new tab
Okay so I'm a google analytics & js noob so I know the absolute basics.
On my site http://www.wildseasonthegame.com I have some humble bundle widgets which are Iframes.
I'm still trying to understand analytics but as I understand it Theoretically I should be having a code like this
something goes here
Now my question is =
Can I replace href with iframe and will it just work? Or will i need to do other stuff (like add some extra JS) to make it work, seeing as how iframes are funny little things
Or do I wrap each iframe in its own a href with a # destination and track conversions that way?
HOw do i differentiate between clicks made to input their email and clicks to purchase?
Any other suggestions how I can track the conversion offsite. Humble bundle has an off site thank you page, but It doesnt look like it redirects back to myne, let alone guarantee tha tpeople will arrive at my page instead of closing their browser after the transaction.
If content is iFramed in you're unfortunately going to have a hard time getting any tracking on it thanks to the same-domain policy. The best way would be to add tracking code to the pages iFrame'd in... but good luck getting Humble Bundle to add your code to their pages. You can get some click tracking on it, but it'd literally just be clicks anywhere on the iFrame.
Due to an issue that came up with a website I have to use javascript for all of the links on the page.
like so...
<img src="image.png"/>
Will having many links with javascript on the webpage slow it down significantly?
Does the Javascript run when the page initially loads or only when a link is clicked?
EDIT: For those asking why I'm doing this. I'm creating an iPad site, when you use the 'add to home page' button to add the site as an icon, it allows users to view the site with no address bar.
However everytime a link is clicked it reopens Safari in a new window with the address bar back.
The only solution I could find was using javascript instead of an html based link to open the page.
For further reference see...
iPad WebApp Full Screen in Safari
2nd answer
"It only opens the first (bookmarked) page full screen. Any next page will be opened WITH the address bar visible again. Whatever meta tag you put into your page header..."
3rd answer down
"If you want to stay in a browser without launching a new window use this HTML code:
a href="javascript:this.location = 'index.php?page=1'"
"
I can see this adding to the bandwidth needs of a site marginally (very marginally), but the render time and the response time on clicking shouldn't be noticeable.
If it is a large concern I would recommend benchmarking the two different approaches to compare the real impact.
What do you mean by slow it down?
Page load time? Depends on the number of links on your page. It would have to be a LOT to be noticeable. Execution time? Again, not noticeable.
The better question to ask is are you o.k. with effectively deleting your website for those without javascript?
Also, if you are worried about SEO, you will need to take additional measures to ensure your site can still be indexed. (I doubt Google follows those kinds of URLs... could be wrong I guess).
EDIT: Now that you explained your situation above, you could easily just "hide" the address bar. See this SO question.
I have put a facebook like, facebook send, and twitter tweet button 10 times on my web page (1 for each article in my thread), but yet the page loads very slowly. Right now the site is just running on my local XAMPP stack but when I comment out those widgets, the page loads instantaneously. Otherwise it takes like 10 seconds to load.
It would be helpful to see the code to make sure you are applying it correctly, but I've experienced similar symptoms before. The way I would render it is by having the associated external Javascript files just before your </body> tag and not in your head. If the connection to the external host is slow, it can cause parallisation issues so you want to load it last.
This is happening all over the web lately. I'll see a slow-loading page and sure enough at the bottom there's a note that facebook or twitter is still loading.
The solution I found was an extension that shows the FB, Twitter buttons but doesn't actually load them unless you click the button. That way your page loads quickly and if FB or Twitter is slow that's their problem.
I use Sharrre for social sharing buttons. I activate it on mouseover so nothing is loaded until the user actually needs it. Hard to get it faster than this. It also supports a few other networks.
I don't load social sharing buttons directly anymore and only do it when there is no other option. Those things are horrible for loading times specially if used multiple times on the same page.
I want to know how Facebook is doing their iframe footer bar. I mean, i know they have an iframe on footer, but i want to know how they are reloading pages without reloading the iframe also, 'cause the iframe always stick there even though the page does reload again. Any ideas/knowledge?
EDITED:
Try clicking on a link which is different section and it changes the url and so far i know, if you try to change the URL, then the page will reload again. Also, try using Facebook on Chrome: you will see it reloads on every new page. It's not AJAX, because the URL wouldn't change if it was AJAX (do little research on URL changing, you will know).
Well, powtac pretty much gave you the answer: Facebook doesn't reload the whole page when you click a link, it requests the new content via XMLHttpRequest and refreshes only those portions of the page that change.
It's pretty slick about this: a naive implementation might not use real links at all, thus preventing you from opening, say, a different Facebook tab in a separate browser tab.
This technique - intercepting link navigation - also allows Facebook to use custom prompts when you try to navigate away without saving, and re-write paths as fragments, allowing it to track the current location in the URL without reloading the page.
FWIW, this question has already been asked and answered - see: How are the facebook chat windows implemented?