Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

HTML - How do i change a Frames URL?


  • Please log in to reply
15 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:48 AM

Posted 14 January 2009 - 04:35 PM

I have a IFrame and when you click BtnHome (A .png image) i want the IFrames url to change to "home.html" How can i do this because i cant seem to find an example on the internet, Thanks, Wolfy87.

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:09:48 PM

Posted 14 January 2009 - 05:35 PM

Let me clarify here. You are trying to use an image as a button, and when that button is clicked, you want the content of the iframe to change? That is simple. You give the frame a name of some sort (name = "myFrame"), and then in the code for the button, you set the target of the url as the name of the frame (target="myFrame").

Is that what you mean?

#3 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:48 AM

Posted 15 January 2009 - 04:20 AM

Hmm, im still not exactly clear with that but i will give it a go when i get home.

Thanks, Wolfy87.

#4 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:48 AM

Posted 15 January 2009 - 02:48 PM

Well i tryed...and sort of failed, it dose not change the frame but dose open the page i want it to change to on a different tab so i am obviosly doing somthing wrong, have a look if you dont know what i meen: OC Code

#5 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:09:48 PM

Posted 15 January 2009 - 06:34 PM

You gave the iframe a name. That was half of the job. Look up how to set a target for an anchor tag. In fact, if you google for that very phrase 'set a target for an anchor tag', you will find examples to show you exactly how it is done.

#6 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,260 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:08:48 PM

Posted 15 January 2009 - 07:19 PM

In your <iframe> tag, you made a typo:
<iframe (...) name="myfame">

It should be

name="myframe"

Additionally, you can use a single tag to make all the links on a page point to the same target frame by using the <base target=""> tag in the <head></head> section:

<head>
<title>Foo</title>
<base target="myframe">
</head>


#7 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:48 AM

Posted 17 January 2009 - 05:53 AM

:D ok that works now but because i am using <a> for it to be a link it gets a box around it, is there a better way of making it a link then but the basetarget seems to have dont the trick :thumbsup:

Thanks, Wolfy87.

#8 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,260 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:08:48 PM

Posted 17 January 2009 - 03:02 PM

You can use the onclick event of the image to launch open a URL using javascript along with the <base target> tag:

<img src="foo.jpg" onclick="document.location='foo.html'" />

Edited by Amazing Andrew, 04 February 2009 - 08:05 PM.


#9 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:09:48 PM

Posted 17 January 2009 - 03:14 PM

@Andrew..

I know that you know the answer to this, but using your method, what happens if he wants a link to open to another page, and not have it open in the frame?

EDIT: Not that I am saying that your method is wrong. My concern is that by doing it that way, you are limiting the options available to the developer. I prefer to work the other way and leave as many options open as possible.

#10 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,260 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:08:48 PM

Posted 17 January 2009 - 06:34 PM

Oh, yeah... that. Obviously the internet needs to change in order to conform to my idea, not the other way around. :thumbsup:

#11 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:48 AM

Posted 03 February 2009 - 12:34 PM

Ok Andrew, works great thanks, now to sort out the layout, looks great at home on fire fox but on IExplorer it looks all disjointed and terrible :thumbsup: but im working on it and im also looking at a bit of CSS at the moment on W3Schools :flowers: and thanks onece again.
Wolfy87.

#12 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,260 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:08:48 PM

Posted 03 February 2009 - 02:27 PM

Ok Andrew, works great thanks, now to sort out the layout, looks great at home on fire fox but on IExplorer it looks all disjointed and terrible :thumbsup: but im working on it and im also looking at a bit of CSS at the moment on W3Schools :flowers: and thanks onece again.
Wolfy87.


Such is the bane of web designers around the world.

Check out http://browsershots.org . Using their free service, you can enter a URL for your web page and get screenshots of how it appears in different browsers and under different platforms (Linux, Windows, Mac, etc.) It takes a few hours for all the results to come back (because the screenshots are from computers that were volunteered for the task.

#13 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:48 AM

Posted 04 February 2009 - 11:40 AM

Aw cool :thumbsup: thanks and i got CSS pritty quickly, saves so much DIV - /DIV =D its great.
Thanks for your help, Wolfy87.

#14 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:03:48 AM

Posted 04 February 2009 - 11:48 AM

And one more thing, how can i take the black border off of my iframe?
Thanks.

#15 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,260 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:08:48 PM

Posted 04 February 2009 - 08:05 PM

I think you'd want to add this to your <iframe> tag:

<iframe ... frameborder="no" />





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users