TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 17, 2024, 04:23:50 PM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 98
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 64
  • Total: 65
  • tino

100% Height Iframe

Started by Lord Anubis, January 17, 2008, 01:06:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lord Anubis

Have you ever had problems creating an Iframe with 100% height?

Well using the code:

<iframe width=100% height=100%></iframe>

DOES NOT WORK WITH MOST BROWSERS, so here is a simple solution for SMF forums...

WARNING: Whenever editing code, be sure to make a backup so you can restore it if anything goes wrong!!!


In the index.template.php for YOUR THEME find:

</head>

Add before


<script language="JavaScript">
<!--
function resize_iframe()
{

var height=window.innerWidth;//Firefox
if (document.body.clientHeight)
{
height=document.body.clientHeight;//IE
}
//resize the iframe according to the size of the
//window (all these should be on the same line)
document.getElementById("glu").style.height=parseInt(height-
document.getElementById("glu").offsetTop-8)+"px";
}

// this will resize the iframe every
// time you change the size of the window.
window.onresize=resize_iframe;

//Instead of using this you can use:
// <BODY onresize="resize_iframe()">


//-->
</script>


Then create a TP article (or custom action) and insert this code (into the source):

<iframe width="100%" scrolling="no" onload="resize_iframe()" id="glu" src="http://your-iframe-source.php"> </iframe>

CHANGE http://your-iframe-source.php to the location of your Iframe


Hope this helps  ;)

noxe

Omg thank you, I needed this badly!

Smoky


falguni1


falguni1

it says

The file you tried to save generated the following error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in index.template.php on line 117

tick

attach your index template here and we can look at why you are getting that error

Hairy

#6
I get the error also, file is attached.

Lord Anubis

#7
What editor were you using Hairy, I ask because your head tag was in the wrong spot

I think I fixed it, give this a try  ;)


Gargoyle

I tried to integrate this all onto one page with no luck. My coppermine currently loads in an SMF page to keep the overall look of the site. I like the concept of your idea. Just haven't successfully implemented it yet.

Looks like some good work there and very helpful

Hairy

Quote from: Lord Anubis on February 05, 2008, 01:49:17 PM
What editor were you using Hairy, I ask because your head tag was in the wrong spot

I think I fixed it, give this a try  ;)



I use Notepad++ but I don't know what was used by the original theme author.

I just tested the new index.template.php but it gives me the following error:

Template Parse Error!
There was a problem loading the /Themes/Pirates-SAMS/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
--------------------------------------------------------------------------------


Parse error: syntax error, unexpected T_FUNCTION in .../Themes/Pirates-SAMS/index.template.php on line 30

21:
22: The menu sub template should display all the relevant buttons the user
23: wants and or needs.
24:
25: For more information on the templating system, please see the site at:
26: http://www.simplemachines.org/
27: */
28:
29: // Initialize the template... mainly little settings.
30: function template_init()31: {
32: global $context, $settings, $options, $txt;
33:
34: /* Use images from default theme when using templates from the default theme?