Are there any good solutions to render scripts rather than just posting the source?

The reason for asking is that when using a mobile or tablet, scripts cannot be copied and pasted in order to see the results.

There are numerous sites which allow pasting scripts and also render results…

I am curious to know the for and against mobile features of any free alternatives.

Edit:
Corrected infuriating text editor replacements :frowning:

Hi @John_Betong, not sure if this will help at all but I made a discovery some time ago that if you set a CSS display:block rule to a script tag it will actually display the script’s code. I was quite surprised by it. Hope it helps in any case.

2 Likes

Unfortunately I do not understand, please supply an example :frowning:

This is what I had in mind:

http://scratchpad.io/mountainous-fact-386

The script below should be displayed:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title> $aUrls[1] $tmp </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<style>
  body {
  padding-top: 80px;
  text-align: center;
  font-family: monaco, monospace;
  background-color: #f8f8f8;
  background-color: #ffe;
}
h1, h2 { display: inline-block;  background: #fff;}
h1   { font-size: 30px;}h2     { font-size: 20px;}
span { background: #fd0;}
.bd1 {border:solid 1px #ccc;}
.bg1 {background-color:snow;}
.mga {margin: auto auto;}
.p42 {padding: 0.42em;}
.w88 {width:88%; max-width:888px;}
</style>
</head>
<body>

<div class="w8 mga bd1 bg1 p42">
  <h1>Welcome to <span>scratchpad.io</span></h1><br>
  <h2>(a realtime html + css editor)</h2>
</div>  
  
</body>
</html>

I am curious to know how long the link is valid before being deleted

Hi John, maybe I’m not understanding you actually…
What I meant anyway is that you can display styles and scripts within the page if you set their display to ‘block’ like so:

<style style='display:block;'> 
    .some-rule {
        color: red;
    }
</style>
<script style='display:block;'>
    console.log('this is some script we want to display in the page');
</script>
1 Like

Unfortunately the feeling is mutual :frowning:

When using a desktop I can copy and paste your script into a new page and render the script.

The problem is when I am using a mobile/tablet…

Copying is OK but I cannot create a new page on the mobile/tablet.

Using a mobile/tablet, the previous post #3 shows sample script which can copied and pasted into the provided link.

The free online application dynamically changes the script and renders this result:

It is most likely I too am not fully understanding, but hopefully I’m in the ball park.

Scenario - desktop:
I see a cool script I want to try. eg.

var gremlin = 'Gizmo'; 
console.log(gremlin);

I copy the code, paste it into a file on my computer, give it the .html extension, open the file in my browser, then look in the console to see if it works.

Scenario - mobile:
I see the same script. I copy and paste it into a file on my device (AFAIK it doesn’t do .html files). at this point I know of no way I can open that file in my browser to see if it works

In other words, even though my desktop browser can render [sic open and run] HTML, CSS and JavaScript files without them being at an actual online or localhost URL, on mobile the browser needs to go to an online page.

1 Like

Yes that is the problem far simpler explained.

I hope it helps other users in supplying points for and against for possible solutions.

I use jsfiddle, but codepen and jsbin are also valid options.

I’ve not used my tablet for development purposes. If I wanted to, and wanted to not use an online site, I’m wondering if a localhost in a flash drive connected to USB might work.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.