PDA

View Full Version : iFrame New Window On Click



rysmith
12-28-2006, 02:04 PM
1) Script Title: iFrame New Window On Click

2) Script URL (on DD): o http://www.dynamicdrive.com/dynamicindex17/randomiframe.htm

3) Describe problem: I want to access the URL of the linked page (sub page) rather than the home page. One possibility is to always open a new window when you click on a page (the home page) in the frame. Can this be done?

jscheuer1
12-28-2006, 03:17 PM
Your question isn't clear to me. I can tell you that using the target attribute with a link will open it in the desired manner, ex:


<a href="whatever.htm" target="_blank">Whatever</a>

will open in a new window. Using "_self" will open in the same window or frame (if the link is in a frame) and using "_top" will open in the same window, breaking out of frames (if any).

rysmith
12-28-2006, 04:37 PM
I'll try to provide a better explanation. Here is a typical page on my Pingxit site: http://www.pingxit.com/cars.htm. If you click on the "VIEW" button at the bottom of the page, the original viewed page opens full screen. One can now copy the URL and save to Favorites etc.

If however, you click on a link on the original viewed page and go to a sub page, and now click the VIEW button, you don't open the viewed (sub) page, but rather the original (home) page. I would like to open the sub page, not the original page.

Here is the existing VIEW button code:

<input type="image" src="button7.jpg" onclick="window.location.href=document.all? document.all.dynstuff.src: document.getElementById('dynstuff').src;" name="I3" width="225" height="25">

jscheuer1
12-28-2006, 07:03 PM
You can't to do that using javascript and HTML alone due to security restrictions in all modern browsers prohibiting the cross domain sharing of information about frames and iframes. If it were not, this is how you would do it. First, you would give the iframe a name:


document.write('<iframe name="dynframe" id="dynstuff" src="" '+iframeprops+'></iframe>')

You would have to make sure that name isn't used by anything else on the page. Next, you would modify your call for your image button:


onclick="window.location.href=window.frames['dynframe'].location.href;"

But, as I say, this will be a security violation and therefore prohibited. There may be some type of server side work around to the violation but, that is beyond the scope of my knowledge and would depend upon what (if any) server side languages you have available to you.

rysmith
12-28-2006, 07:18 PM
John,

Well...I don't want to do anything that is illegal, but it's hard to understand the difference between displaying the home page of a site vs. a sub-page.

I am certain the sites/companies themselves will be delighted to be included in our database however they are displayed.

You mentioned previously that you were working on a different backup code. Any progress?

Any reason you haven't responded to my emails?

Ry

jscheuer1
12-28-2006, 09:13 PM
It's not a question of the law. It is the way security is set up in modern browsers. As with most technological fixes on human behavior, this really only keeps the honest people from doing interesting things while doing nothing to deter criminals who, in the end, will find another scam and/or a way around the tech fix. The main reason for this security 'feature' is to prevent phishing, just read the news and you will see how successful it has been at stopping the practice.

As for my email, are you on my buddy list? Just kidding but, I get so many DD related emails that I have a filter for them. I usually come here to the forums first though.

I'm not sure I was that committed to a back button for this script, if that is what you are referring to.

rysmith
12-28-2006, 10:04 PM
John,

In general, my email referenced the need to take the next step with Pingxit and turn it into a database driven site. It seems to me this is the only way to solve the problems of setting up a proper Favorites function, Ratings, etc. - see: http://www.pingxit.com/test6.htm for a possible design of what I'm looking for.

I had enquired as to whether you or one of your associates did consulting in this area.

Ry

jscheuer1
12-29-2006, 05:04 AM
I had enquired as to whether you or one of your associates did consulting in this area.

Personally, no - and I have no associates as yet. I'd suggest shopping your project here:

http://www.rentacoder.com/RentACoder/default.asp

or on similar sites. One thing I might consider is acting as a project coordinator and/or oversight if you end up requiring multiple coders. I am not in the business of finding coders though.

One bit of free advice that I think I mentioned before is that your iframe does not appear in Opera. This was a good move at the time that the code for it was originally written but, no longer applies to that browser. So, it should be changed at some point in the development process.

rysmith
12-29-2006, 05:37 AM
John,

Thanks for the input. I have used RentACoder in the past but I need to define a little better exactly what is needed for this project. I try to model everything to the extent I can.

I'll keep the Opera problem in mind and I'll keep in mind your project coordinator thought.

Ry