|Join Nairaland / LOGIN! / Trending / Recent / New|
Stats: 2,695,093 members, 6,352,459 topics. Date: Wednesday, 23 June 2021 at 11:08 AM
|My First Post Of 2009 - A Frameset Question by yawatide(f): 6:55pm On Jan 01, 2009|
As they say, practice what you preach. In 2008, I preached that in 2009, we should all post things from which we can teach and/or learn. This is my first of what promises to be many:
I recently revamped my new site, basically a collection of links to other actual news sites. I decided, in order to maximize ad revenue, to go with frames. I don't like frames but in order to boost site traffic and increase the potential of people clicking on ads, I have decided to cast my "hatred" of frames to the side for the time being, but I digress.
The idea is, the top frame (A) will have a header for my site while frame B has the website from which I am referencing for news. I am done with that part though. The issue arises with sites like punch where it seems they are detecting if they are being pulled up in a frame and if yes, they kick out of the frame into the main window, as if you accessed them directly. I have created a workaround in those cases by using "taget="_blank" as I don't want my site to lose focus but I am figuring there is a way around this and hence my question:
Is there a solution out there that any of you know or have written than can check to see if thesite in question is sniffing for frames and if so, negate that sites's script, thus putting its site in frme B? Call it a "frames detector detector".
I would appreciate your response(s). Thanks in advance.
|Re: My First Post Of 2009 - A Frameset Question by lagerwhenindoubt(m): 1:15pm On Jan 02, 2009|
googled up this, could be useful, i simply lacked the courage to continue after the first few lines.
Should sniff out sniffers and I think its called Cross-Site Scripting
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 1:35pm On Jan 02, 2009|
Check this website to see if what is done there is exactly or close to what you want to do.
|Re: My First Post Of 2009 - A Frameset Question by lagerwhenindoubt(m): 2:10pm On Jan 02, 2009|
it looks (on the surface) that the Punch website detects when it is being loaded via a frame and changes the frameset behavior to load parent _parent. which loads in the same window as the site where the load link request came form, so if you visited mynewsframe.com and clicked on punchng.com rather than load it in a frame on mynewsframe.com, it kicks it out and loads punchng.com so you will need to hit back button to get back to other newspaper sites.
|Re: My First Post Of 2009 - A Frameset Question by yawatide(f): 4:03pm On Jan 02, 2009|
Omni and larger, thanks.
Yes, the site you showed is how my site works currently. That is the part in my post that I said I have since done. The issue I am having is what you will notice if you scroll the left column to where "punch" is and click the "punch" link. Notice what happens after a few seconds (hint: you are no longer on the site you sent me)
Yes, the solutions you sent me are cross-site/dynamic scripting, very powerful concepts. I am liking your idea of using it to redefine the "punch" function that is causing the frame overriding. Having said that, I don't think it is efficent because there are 3 other good news sites that I also go to for news that have the same issue. Here are potential problems that I foresee with your approach:
1) What happens if Punch changes their function name tomorrow?
2) As I said, 3 other sites have the same behaviour. Am I to go searching on those sites for their overriding functions as well? If yes, refer to #1 above. Also let's not forget, I would then have to have separate function calls for each news site. Might be fine for 3 or 4 sites but what happens if I expand to 100 and 50 have the same behaviour?
I will thus use what I am using now which is to "target=_blank" on those specific sites for now while looking for a better solution. Having said that, I do really appreciate your answers. We have all definitely learned something from this.
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 4:23pm On Jan 02, 2009|
New year bonanza for me there
I still have more issues to ask maybe here or in a new thread. Till then.
|Re: My First Post Of 2009 - A Frameset Question by AbidemiA: 12:25am On Jan 03, 2009|
You can achieve this by streaming first page of punch website, convert the streamed content to string, then pass the string as HTML code see how i implemented it here http://adten.net/News/index.aspx?tab=8 if this is what you need let me know the code behind is less than 20 lines.
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 1:36am On Jan 03, 2009|
@yawa, i can help you a little there - there is a way you can forcefully pull data from other sites and display them on your site. A DHTML technique - the problem is that - it is not specific, i must configure my script per site - so that i can pull whatever aspect i need - but if you want to pull the entire page into your site - no problem - i should still be able to manage it.
You may want to take a look at this page: http://mwebng.net/?net=tt - it pulls a thread i created from nl to my site - via ajax - but if you click on any link in there, you will find yourself in nairaland - on the same thread. Though external links to other sites posted will open the relevant sites in a blank window as well. And it only costed me about 10 lines of php codes.
|Re: My First Post Of 2009 - A Frameset Question by yawatide(f): 4:19am On Jan 03, 2009|
Pretty interesting Abidemi and dhtml. How about each of you post your solutions on the forum so we all can take a peek and perhaps debate on the pros and cons of each as well as decide which is best?
Thanks for your input. Wow! 2009 is rolling to a good start, posts-wise
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 4:53am On Jan 03, 2009|
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 4:58am On Jan 03, 2009|
index.php - the insertion code
punch.php - the engine
And when u are using it - please count the number of seconds and compare it with the other solution up there.
And if u want an ajax interface to it, just tell me, i made sure all my ajax scripts are well optimized, and work as good as jquery just faster because they are well optimized and are 2009 compliant!!!
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 5:42am On Jan 03, 2009|
@Abidemi_A and dhtml
Is there no way to keep them entirely all framed without having them to pop out when you click on a link? I mean the Punch website?
|Re: My First Post Of 2009 - A Frameset Question by AbidemiA: 6:54am On Jan 03, 2009|
Here is the code
StringBuilder sUrl = new StringBuilder();
WebRequest oReq = WebRequest.Create(sUrl.ToString());
StreamReader sStream = new StreamReader(oReq.GetResponse().GetResponseStream());
StringBuilder sOut = new StringBuilder();
string abid = sOut.ToString();
abid = Regex.Replace(abid, "target='pollwindow'", ""
abid = Regex.Replace(abid, "target='_blank'", ""
abid = Regex.Replace(abid, "target='_self'", ""
abid = Regex.Replace(abid, "href", " target='_blank' href"
Literal1.Text = abid;
On my HTML page I have this
<base href="http://punchng.com/" />
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
If you want to test for speed use this link http://adten.net/News/index2.aspx?tab=8
The first link I posted will take about x12 of the seconds that it is required to load the new link. Reason, I have 12 news sites that I am loading at the same time. Justification, you can navigate easily through the news sites without page reload until you are done with news section.
It is possible, you can use regular expression to filter all links on the page, change the links values to other values that are directed to a frame on your page. I think this has legal implication , punch may sue you for circumventing the security they put in place to protect their content.
You will do the manipulation here
abid = Regex.Replace(abid, "href", " target='_blank' href"
If you need to make it work for research purpose, mail me at firstname.lastname@example.org
When I clicked on links from your solution I got Error 404. Also, I noticed that you hard coded ref to some images, what happens when the names or refs of the images are changed? I think you can overcome this problems by setting the base ref of your content block to Punch domain.
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 7:25am On Jan 03, 2009|
Thanks for the the code sample Abidemi_A.
As for the Punch, I'll let them to their security thing.
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 8:14am On Jan 03, 2009|
Ok @Abidemi, u win - i only spent a few minutes on that - so i had to do some hardcoding - but have u seen my nairaland filter on http://mwebng.net/?net=tt there is not hard coding in that, and it displays beautifully.
But, dont let us start a debate on which one is better - asp.net or php - that will get very rough. On the bright side, i do asp.net too but i am yet to use it in a real life project.
|Re: My First Post Of 2009 - A Frameset Question by yawatide(f): 1:26pm On Jan 03, 2009|
First and foremost, I want to really thank Abidemi and dhtml for their posts. This is EXACTLY what I craved for in 2009 and beyond. This shows that we have matured from the "site review" days. Once again, thanks.
Since my site uses PHP, I would be tempted to use the dhtml approach. One looking at it further though, granted it is some pretty nifty code, I have a question:
$search = array("src='images", "src='canada.gif","src='imeages.gif", "src='zenith.gif", "src='punch.gif","a href",'src="/',"<script","</script"
I assume that the $search part of the code has to do with the various ads on the punch site right? If yes, then does this imply that I have to do same for each paper that I access? If yes, imagine if I have 100 papers to peruse. That would be a nightmare.
Do I hear you say, "yawa na wa for you o! ok, if it bugs you that much, don't use that part"? Okay I hear you o! I don't have to but I just had a question okay?
Once again, thanks to the 2 posters.
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 1:51pm On Jan 03, 2009|
The filter i created for nairaland on my site is only 10 lines and can pull any thread on nairaland into a site pictures and all once you specify the link to the thread - and without changing any codes. For punch however, there code is not well structured. Besides i was very sleepy as at the time i wrote that code - i will review it and give you something more reliable. i only studied the code to their home page. The code i gave you was just a sampling code - i will rewrite it later this night and repost it back on this thread. and i will tell you how to use it. Meanwhile, it will be good of you to give me a better idea of what precisely you want to do - i gather you want to frame the site [and do do you the links to open in same window or blank window?] - whatever, just paste it here - i will analyze and code later - i am tryin to finish a client job right now
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 9:39pm On Jan 03, 2009|
I am working on the stuff now, please wait, 50% completed, packaging, , 80% tested and working,
90% working, is now pulling contents from multiple pages and displaying them in frames,
And it is 100% completed. Yes!!! I am Evil!!!!! hoo-hooo-haaaa-haaaa-haaa
Doing test running, and preparing to dump codes here, please wait, shit i missed my dinner!!
No problem, yawa can always post me another dinner -
You will be needing this small utility to encode your urls http://mwebng.net/utils/escape/ - nothing special just to escape your url
The demo is http://mwebng.net/punch/ - now to explain -
You can link to directly to any punch web page by using punch?url=sfsgsgwg because the urls can contain illegal characters like question marks is why i created utility http://mwebng.net/utils/escape/
This now leads to the next issue of the links opening into the parent window - i only know of one hard way to solve that problem
- i am still considering,
However to make the links open in a blank window - u can add the line:
$contents = str_replace("a href", "a target='_blank' href", "$contents"
into the php code above.
To make links open in the same window:
And not that you do not have to manipulate this code - the solution is now complete - i think
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 10:03pm On Jan 03, 2009|
I love your skill of modifying your posts rather than making unnecessary random posts. Keep it up. This year smells lovely . A journey well began == half gone
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 3:31am On Jan 05, 2009|
In the last post i made on this subject - it can load into frames and the links will open in the same frame.
|Re: My First Post Of 2009 - A Frameset Question by yawatide(f): 10:23pm On Jan 05, 2009|
Thanks guys for all your responses, granted I must confess it was a lil more than I was expecting
Having said that, dhtml, I have responded to your question here: https://www.nairaland.com/nigeria/topic-212088.0.html
It appears you have made a habit of asking me the same question all over the place
That shouldn't take away from the solutions posted here though. To all, thanks once again.
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 10:29pm On Jan 05, 2009|
iight lady - that will be all for now - i just needed to know i have not scripted in vain - i hate wasting scripts!!
|Re: My First Post Of 2009 - A Frameset Question by yawatide(f): 10:56pm On Jan 05, 2009|
blv me, u hvnt. Even if I don't use it now, blv me, there are ppl (much like u were, hmmm ) who are visiting this thread and appreciating all you have done so far, though they probably won't say a word
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 11:06pm On Jan 05, 2009|
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 1:45pm On Jan 06, 2009|
I know that - I am used to it - it is just a pity that i have been in a white forum - all this years - flowing along with them - and forgetting my brothers and sistas here - anyways - i am only one person - i will do as much of free service i can do - and balance it with my own personal life - i just love helping ppl whether they appreciate it or not is not what is important - there are those that appreciate and there are those who do not - i have settled that issue with myself some few years back.
|Re: My First Post Of 2009 - A Frameset Question by yawatide(f): 3:53pm On Jan 06, 2009|
uhhmm, and what's the difference b/w white students and black students? Aren't we all, at the end of the day, human beings?
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 11:54pm On Jan 06, 2009|
U answer yourself, i have more preference for my fellow blacks anyway. Lemme not say more than dat just so i dont break forum rules.
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 4:39am On Jan 07, 2009|
TOPIC: My First Post Of 2009 - A Frameset Question
Don't wake sleeping dogs here. We are mixed in here so don't let that thing on your minds creep in.
All animals are equal but with different experiences and developments
|Re: My First Post Of 2009 - A Frameset Question by lagerwhenindoubt(m): 3:08pm On Jan 08, 2009|
man i am so out-dated
|Re: My First Post Of 2009 - A Frameset Question by OmniPotens(m): 2:18am On Jan 09, 2009|
Out-dated as in
|Re: My First Post Of 2009 - A Frameset Question by Nobody: 8:52pm On Jan 10, 2009|
***Wondering who will win, i still have a chance i hope! ***
Audience cast your votes O. I have already prepared my own quiz - when i get back to my laptop after my leave next week i will post it!!
|Re: My First Post Of 2009 - A Frameset Question by lagerwhenindoubt(m): 1:00pm On Jan 12, 2009|
out-dated as in. if you know how much junk code i would have had to patch to get to this level of coming at a solution as the ones presented here, you will ban me for life.
|Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health |
religion celebs tv-movies music-radio literature webmasters programming techmarket
Nairaland - Copyright © 2005 - 2021 Oluwaseun Osewa. All rights reserved. See How To Advertise. 203